Introduction: IR Module Tutorial

About: A very very very very very Young Maker......

Test your IR module if it works!

Supplies

Arduino    x1 ***Any Arduino, I use Arduino Uno.***

IR module x1

LED           x1

Wire         x3 *** 3 piece normal wire/jumper wire/etc

Step 1: Circuit Diagram

Connect the wires to the Arduino as shown.

Note:

No breadboard required.

Picture above is just a reference


Circuit:

Led + to any digital or analog pin

Led - to Arduino GND

IR VCC to Arduino 5V

IR GND to Arduino GND

IR OUT to Arduino any digital or analog pin


Step 2: Coding

For better result, you can download Arduino IDE Software in https://www.arduino.cc/en/software

Code :

void setup()

{

 pinMode(A0,OUTPUT); //depends on where your led connected

 pinMode(A3,INPUT); //depends on where your ir module connected

 Serial.begin(9600);

}

void loop()

{

 if (digitalRead(A3)== LOW)

 {

  digitalWrite(A0,HIGH);

  Serial.println ("Obstacle detected");

   

  delay(100);

 }

 else 

 {

   

  digitalWrite(A0,LOW);

  Serial.println ("No obstacle");

  delay(100);

   

 }

}

  

Step 3: Testing

***Remember connect the cable to your PC***

Open your Arduino IDE and click serial monitor (the magnifier-like icon)

What should you see:

When the module sensed obstacle, the serial monitor will print "Obstacle detected" and your led will bright; else the serial monitor will print "No obstacle" and your led will off.

Step 4: Done

Congrats to all who succeed!

Have fun!

Thanks for watching!