The OSOYOO IR Track Sensor is essentially a combination of IR LED and IR detector which can be used to detect black and white colors. It works by sending a beam of IR light from IR LED toward the surface. The IR detector will get the reflection signal from surface and judge if the surface is white or black color.
In this lesson, we will show you how to program Osoyoo Uno board and get surface color status from IR tracking sensor.
Connection:
First, please plug Osoyoo Magic I/O shield into UNO board. Then connect the tracking sensor module to the D2 port of the Magic I/O shield with a 3-pin PNP cable as below:
In this experiment, A LED is attached to D13, and IR tracking module is connected to digital D2 of the Uno board. Our purpose is to make following result: When the tracking sensor detects reflection signals (white), the LED will be on. Otherwise, it will be off (black line).
Note: The sensitivity of the infrared sensor is adjustable – you may adjust it by the screw( on the back of sensor)with a screw driver.
You can download the code directly, then click “Open” in Mixly to choose the code you download:
Or you can do as following operations:
After above installations are completed, connect the OSOYOO Basic Board for Arduino to your computer using the USB cable. The green power LED (labelled PWR) should turn on. Open the Graphical Programming software Mixly and do following graphic operations:
Drag out the if block from the Control category. We also need add an else sub-block to this if do block. To do this, just click the setting icon inside if do block, drag out an else sub-block and connect it to if block, then Click setting again to turn off the setting window.
Drag out the first block from Logic category,then drag out the DigitalRead PIN# block from the In/Out category ,set pin 2 as input.Last drag out HIGH block as per picture.
Drag out the DigitalRead PIN# block from the In/Out category,set pin13 as input and HIHG as Stat.
Drag out Serial PrintIn block from SerialPort category.
Drag out Hello block from Text category and set text as Detect:Black!
Drag out the DigitalRead PIN# block from the In/Out category,set pin13 as input and LOW as Stat.
Drag out Serial PrintIn block from SerialPort category.
Drag out Hello block from Text category and set text as Detect:White!
Save and upload program to OSOYOO Basic Board for Arduino.
A few seconds after the upload finishes, set it down on a piece of paper with a dark line (at least ½” wide). You may use a Sharpie Marker, electrical tape, or dark paint. When the module gets on a black line, it output high and the corresponding LED stays off, the Serial Monitor output: “Detect: Black!”.
when it meets a white area, it outputs low and the LED lights up, the Serial Monitor output: “Detect: White!”
Note: The black line should be wider than the IR track sensor.
DownLoad Url osoyoo.com