hrsajjad844
Published © MIT

Obstacle Detection Using IR Sensor

IR sensor is used to detect objects. When an object is near the sensor, and led turns ON.

AdvancedShowcase (no instructions)11,834
Obstacle Detection Using IR Sensor

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
IR Transceiver (Generic)
×1
5 mm LED: Red
5 mm LED: Red
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Capacitor 100 µF
Capacitor 100 µF
×1

Story

Read more

Custom parts and enclosures

Pin Diagram

Here project pin diagram

Code

Code

C/C++
Here is the project code
int analogInPin = A0;  // Analog input pin that the potentiometer is attached to
 
int led =10;
int sensorValue = 0;        // value read from the pot
 
void setup() {
  // initialize serial communications at 9600 bps:
  Serial.begin(9600);
  pinMode(led, OUTPUT);
}
 
void loop() {
  // read the analog in value:
  sensorValue = analogRead(analogInPin);
  Serial.print("sensor = " );
  Serial.println(sensorValue);
 
  delay(200);
  
  if(sensorValue<80)
  {
    digitalWrite(led,HIGH);
  }
  else
  {
    digitalWrite(led,LOW);
  }
}

Credits

hrsajjad844

hrsajjad844

1 project • 16 followers

Comments