In this tutorial, we will be using an IR proximity sensor. We are going to program our surilli with a very basic program for line sensing. This program detects line (black and white)--while value of sensor is 1, it indicates that it is a black line, and when white line is detected its value becomes 0.What Is an IR Sensor?
This IR proximity sensor is a multipurpose infrared sensor which can be used for obstacle sensing, color detection, fire detection, line sensing, etc and also as an encoder sensor. The sensor provides a digital output.In this case, the sensor outputs a logic one (+5V) at the digital output when it detects black line in front of the sensor and a logic zero (0V), when there is white line in front of the sensor. An onboard LED is used to indicate the presence of black and white. This digital output is directly connected to Surilli wifi.STEP 1: Set Up Arduino IDE for Surilli
Make sure you have selected the right port, board and processor for the Surilli as shown in the picture below and it is programmable (compile and upload “Blink” from File>Examples>Digital>Blink onto your Surilli to check if everything is working fine).STEP 2: The Circuitry
The circuitry is very simple. It's mostly the programming and it involves adjustment of potentiometer, which will be described in Step 4. Follow the Figure 1 to set up your hardware.
- Now you have completed setting up your hardware and Arduino IDE. Copy and paste the Arduino sketch given below into your Arduino IDE and hit upload.
- After it is uploaded, the IR sensor will start working.
- Observe your results on serial monitor of Arduino IDE.
Adjust the potentiometer (distance adjust) located on your IR sensor according to your requirement. Play with the program to see how it reacts to different values and logic. This will develop your understanding about IR sensor so you can use them in your practical application.
If you make something fun and interesting do share it with our community.
That’s all for now. If you have any queries, visit surilli.io or contact our support. Stay connected with Surilli family for more amazing stuff. :-)