Category:

Arduino

Title:

Obstacle Detection System with Infrared Obstacle Escape Sensor

The KY-032 sensor is a sensor known as an infrared barrier detection sensor. The KY-032 obstacle detection sensor is generally not used for distance measurement, unlike the HC-SR04 ultrasonic distance sensor. The threshold set by the potentiometers on it sends two different signals, either high or low, depending on the proximity level. The KY-032 sensor has both an infrared receiver and a transmitter. It sends the signal according to the distance and proximity to the distance of the infrared rays detected by the KY-032 sensor. Here, if the value sent by the sensor is high, HIGH means no obstacle. The sensor sends a low, meaning LOW. With this sensor, robot projects can be used to avoid obstacles and can be used as switch-on switches. So you can see the KY-032 button function. The following example shows the use of the KY-032 sensor and the dc motor, led and buzzer together. According to this example, projects such as robot avoiding obstacles, cars standing in front of obstacles, lights that can be lit or turned off by hand, or KY-032 sensor can be included in more complex projects.

Project Video


The point to be considered when using the KY-032 obstacle detection sensor is to make the correct adjustment of the potentiometers on the ground. When this is not done, the sensor may not send the correct values ​​because the distance is not detected, and you may call the sensor which is actually intact. Therefore, if the sensor does not work correctly in the first stage, you should adjust the potentiometers on it. Another issue that should be considered is that the sensor signaling HIGH signaling indicates no obstruction is detected, and the signal is detected when the LOW signal is detected. This can cause confusion.

Project Scheme

ky-032 engel kaçış sensörü, dc motor, led ve buzzer

Necessary Materials

  • Ardunio UNO
  • Dc-Motor
  • 330 Ohm Resistor
  • Led
  • Piezo Buzzer
  • Jumper Cables

Ardunio Source Code

//This coding was made by codeforyoungs.com on 29.11.2018
const int led = 4;   //First of all we do pin definitions
const int dcMotor = 2;
const int buzzer = 8;
const int irSensor = 12;
int val;
void setup(){
  pinMode(led, OUTPUT);
  pinMode(dcMotor, OUTPUT);
  pinMode(buzzer, OUTPUT);
  pinMode(irSensor, INPUT); //KY-032 pin will be INPUT
}
void loop(){
  val = digitalRead(irSensor); //We pass the value from sensor pin to variable
  digitalWrite(led, !val);     //If signal is LOW then led open. 
  digitalWrite(dcMotor, val);   //If the signal is HIGH thats mean no obstacle. Dc motor will start.
  if(val == LOW)  //If signal is LOW thats mean there is obtacle. Buzzer will be open
  tone(buzzer, 528, 100);
  }
  delay(1);
}
968 views
COMMENTS