 Hello everyone! In this video we are going to learn all about IR sensor, how it works, how to interface it with prototyping boards like evive and Arduino and how to program it in picture blocks. Finally, we'll take a look at the wonders we can create using it. Let's begin! First, let's understand what an IR sensor is, take a look at its component and see how it works. The IR in the name stands for Inferred Radiation. It is a type of light that falls outside the visible spectrum and can be felt as heat. The LED here is the IR LED. It works as the IR transmitter. The component next to the IR LED is a photo diode that works as a receiver. The transmitter emits IR light and the receiver keeps checking for the reflected light. If the object is present in front of the IR sensor, the lights get reflected back after hitting the object and the receiver detects it. This is how IR sensor detects the object in front of it. The blue knob here is a potentiometer. You can control the range that is from how far you want to detect the object by changing the value of the potentiometer. The IR sensor is a digital sensor, thus its output will be either 1 or 0. Now that we have a little idea about its working, let's have a look at how to interface it with evive and see it in action. First, connect its VCC pin to the plus 5 volt pin on evive. Next, connect its ground pin to evive's ground pin. Then, connect the out to evive's digital pin too. An IR sensor has two small LED indicators. One for power, which is on the entire time the sensor is on. The other is the signal LED, which detects the object. Whenever an object is detected, the signal LED turns on, otherwise it remains off. Let's test whether the IR sensor is working or not. Bring your hand in front of the IR sensor. In doing so, the signal LED should turn on. If not, calibrate the IR sensor. Adjust its range for object detection using the potentiometer. Once the IR sensor is calibrated, it is ready to use. Now let's see how to display and read the sensor data on the evive screen. Open evive's menu, navigate to pin state monitor, then select digital pin state. Now take your hand close to the IR sensor. In doing so, you'll see that the signal LED lights up, and zero is displayed next to pin two on evive's screen. As soon as you take your hand sufficiently far away from the sensor, the LED will turn off and the state goes back to being one. Now let's program the IR sensor in Pictor Blocks. It is a graphical programming software based on Scratch Blocks. You can download it from the link given in the description box below. Before doing anything else, connect evive to your computer using a USB cable. Next, open Pictor Blocks. Then click on the board button and select evive from the drop-down. Now from the dialog box that appears, choose the appropriate serial port. Before writing the script, make sure that the firmware is uploaded. If not, upload it using the upload firmware button. Now let's make a small script to make Toby. Let us know whether an object has been detected or not. The IR sensor gives zero as output if it detects an object and one otherwise. We'll monitor the output of the IR sensor using an evive's block. If the sensor does not detect any object in front, Toby should say no object detected. When it does, Toby should say object detected for two seconds. To run the script continuously, we'll use the forever block. Place when flag click hug block above the forever block. It will ensure that the script runs when the green flag is clicked. Click the flag and bring an object in front of the sensor to test the script to ensure that it is working perfectly fine. Now let's make a script to use the IR sensor without having evive connected to the computer. For that, we'll work in the upload mode. To work in the upload mode, click the toggle button here. Now add an F block to monitor the output obtained from the IR sensor. On detecting the object, evive's buzzer should ring. Place the Playton on block inside the space in the F arm and select a tone of your choice. Use a forever block to run the code continuously. Place the event evive starts up head block to execute the program. Finally, upload the code using the upload button. Now that you know how to work with IR sensor, there are a number of projects you can make using it. Like an automatic door and a color sorter, you can also use it to perform physics experiments such as measuring the time period of a pendulum and many more. That's it for this video. If you liked it, give it a thumbs up and share it with your friends. For more such educational content, subscribe to Stempedia and follow us on Facebook, Instagram and Twitter. Bye-bye.