Skip to main content

INFRARED SENSOR WORKING TUTORIAl WITH ARDUINO

 INFRARED SENSOR WORKING TUTORIAl WITH ARDUINO

INFRARED SENSOR:

                                      The infrared sensor are the obstacle detection sensor with detects the object in front of it and it consists of the ir transmitter and the ir receiver in it.The infrared sensor consists of the trimmed capacitor in it so the detection of object can be controlled with it.It has the 5v input and Gnd in it and has the output pin it when obstacle detected the votage comes through it.Let's see the working tutorial of it with aurdino.

COMPONENTS REQUIRED:

                                   1)INFRARED SENSOR
                                   2)ARDUINO UNO
                                   3)CONNECTING WIRES
                                   4)A PC

CONNECTION DIAGRAM:




WORKING:

1)Connect Infrared sensor +vcc to 5v of Arduino and the gnd  of Infrared sensor to Gnd pin of Arduino.

2)Output pin of the Infrared sensor to the 2 pin of the Arduino and just copy the code give below.

3)And go to the Arduino to and paste the code.

4)Compile the Code and upload it.



SOURCE CODE:


int obstaclePin = 2;  //NBSL COMMERCIAL
int hasObstacle = HIGH;


void setup() {
  pinMode(obstaclePin, INPUT);
  Serial.begin(9600); 
}
void loop() {
  hasObstacle = digitalRead(obstaclePin);
  if (hasObstacle == LOW)
  {
    Serial.println("Nothing Ahead!!");//If obstacle detected
    delay(200);
  }
  else
  {
    Serial.println("Obstacle"); //No obstacle
  }
  delay(200);
}


Tutorial for this is given below;

        

Comments

Post a Comment