B6: Obstacle Detector using IR Sensor

AR-B6: Obstacle Detector using IR Sensor

This entry is part 6 of 13 in the series Arduino Basic Circuits

This code is used to beep the buzzer when obstacle is detected by the IR sensor in front of it. When there is no obstacle, the buzzer remains OFF.

Required Material

Arduino UNO Board – 1, data cable – 1, IR Sensor – 1, Buzzer – 1, Jumper wires – 5.

Working

After uploading the code in Arduino UNO board, place your palm near the IR sensor. This will make output of IR sensor LOW and the buzzer will be ON. When you remove your palm, the buzzer will be OFF.

The Code

This code detects the obstacle in front of IR sensor. First upload the following code in Arduino UNO, construct the circuit using following connection diagram and then test the results.

int buzzer = 11;
int irs = 7; 

void setup()
{
  pinMode(buzzer,OUTPUT);
  pinMode(irs,INPUT);
}

void loop()
{
  if(digitalRead(irs)==LOW)
  {
    digitalWrite(buzzer,HIGH);
  }
  else 
    digitalWrite(buzzer,LOW);
}


Procedure & Precautions

  1. First type the code correctly in Arduino IDE software.
  2. Then connect the Arduino board to computer through data cable and click on “Tools” menu.
  3. Then select “Arduino board” and respective “COM” Port.
  4. The upload the code in Arduino UNO board.
  5. Once the circuit started, place your palm in front of the IR sensor.
  6. Immediately the buzzer will be ON.
  7. Now remove your palm, in front of the IR Sensor.
  8. The buzzer will be OFF.
  9. Remember that the range of IR sensor is short. So place your palm or any object near the sensor.

Circuit Diagram

B6: Obstacle Detector using IR Sensor
Series Navigation<< AR-B5: Chasing Effect of LEDsAR-B7: Object Counter using Serial Monitor >>
Dr. Dattaraj Vidyasagar
Dr. Dattaraj Vidyasagar

M.S. Electronics & Telecomm. (Cleveland Institute of Electronics, Ohio), Associate Member (IETE, Kolkata), Panelist on Dr. Homi Bhabha Foundation, Google certified educator (Level-1), Mentor of Change (MoC-1619) Niti Ayog, Government of India, International Robotics Trainer, Veteran of Applied Electronics since 35+ years.

0 0 votes
Article Rating
Subscribe
Notify of
guest

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
1
0
Would love your thoughts, please comment.x
()
x