Assalam O Alaikum friends! welcome to simple
homemade projects in this video i am going to show you that how you can use an arduino
uno with infrared sensor module so first of all you will need an arduino, an infrared
sensor module and three male to female jumper wires. Now connect the vcc and ground pin of the
infrared sensor module to 5 volts and ground pin of arduino uno respectively. After it connect the
output pin of the infrared sensor module to pin 12 of the arduino uno. Here comes the IDE part.
In void setup you have to define the pins as i am going to use pin 12 as the input pin
and you can use any of the digital pins as input in my case i am going to use pin 12 and for the
output pin i am going to use pin 13 because the built-in led of arduino is connected with pin
13. you can also use any of the other pins but you have to use an external led. In the
loop part we have to detect whether the sensor is giving us a value or not as we all
know that the infrared sensor gives a low value upon detection of an object so for its
detection i am going to use an if statement that if the object is detected at pin 12 then
the output which is pin 13 will be turned high so if digital read at pin 12 equal equals low
this is the condition which is being checked by if if statement and if it is true then the led at
the pin 13 or the pin 13 will be turned high and in all other conditions the pin 13 will be
kept low so for it i'm going to use else statement so this was our whole code and now i
have to compile it and after compiling you just have to plug in your arduino to your
computer by using the usb cable and before uploading make sure that you have selected the
correct board and the correct communication port and after it upload the code to arduino and here you can see the code has been uploaded and it is working well upon detection of the
object the sensor will give a low signal which is judged by the arduino and in return it will turn
on the built in led which is connected to pin 30. you can also change the
range of the infrared sensor by using a screwdriver and
turning the potentiometer on it by rotating it in one direction
it will decrease the range and in other direction it will increase the range so that was all from my side i hope you like it so don't forget to share and
subscribe take care Allah Hafiz