Working With IR Sensor And Arduino

Introduction

 
In this article, we are going to see how to work with infrared sensors and Arduino to create a line follower Bot. The infrared sensors use the Laws of Reflection to detect a Black Line. The basic phenomenon happening is a black body absorbs the heat radiation much more than a white body absorbs it, the same phenomenon is used in solar cookers. The Op-Amp compares the input and output of the sensors and hence produces the output to the Arduino in the form of digital signals.
 
Requirements
  1. Arduino UNO
  2. IR sensor
  3. Gear Motor
  4. Robot chassis
  5. Connecting wires
  6. L293D motor drivers
Circuit Diagram
 
IoT
 
The process is a comparison between the sensor1 and sensor2. If sensor1 is high and sensor2 is low, then turn to the left of the Blackline; similarly vice versa for a right turn. If there is no input the bot will stop moving.
 
IoT
  1. Open the Arduino Software.
     
    IoT
     
  2. Initialize the Pins used in the codings.
     
    IoT
  1. Declare whether it's input or output.
     
    IoT
  1. In the void loop, the coding for the Bot movement is provided. We declare Left motor as LM and Right motor as RM and IR Sensor value as LS and RS as per the requirement.
     
    IoT
  1. Compile the coding in the Arduino. Go to sketch, then compile, we can use shortcut ctrl+R.
     
    IoT
     
  2. Upload the code, put a black line and test the Bot movement. Here is an example from the internet.
     
    IoT

Summary

 
In this article, we learned how to work with the IR sensor and Arduino and create Line follower Bot using gear motor and L293D motor driver. This can be further modified to create an automated delivery system for the household.