Note: ALL OSOYOO Products for Arduino are Third Party Board which is fully compatitable with Arduino


Buy from US Buy from UK Buy from DE Buy from IT Buy from FR Buy from ES ここでご購入を!


  1. Introduction
  2. Preparations
  3. About the IR Track Sensor
  4. Connection
  5. Upload Sketch
  6. Program Running Result


The IR Track Sensor is essentially an IR LED and an IR detector. It works by transmitting a beam of IR light downward toward the surface. In this lesson, we will show you how the IR Track Sensor works and how to use it with the Osoyoo Uno board.




About IR Track Sensor


First, please plug OSOYOO Magic I/O shield into OSOYOO Basic Board:

Then connect the OSOYOO IR tracking sensor to the port D2 of the Magic I/O shield with 3-pin PNP cables as below digram (please put the switch on tracking sensor to D):

Code Program

After above operations are completed, connect the OSOYOO Basic Board to your computer using the USB cable. The green power LED (labelled PWR) should go on.Open the Arduino IDE and choose corresponding board type and port type for you project. Then load up the following sketch onto your OSOYOO Basic Board.

const int trackingPin = 2; //the tracking module attach to pin 2
const int ledPin = 13; //pin13 built-in led
void setup()
  pinMode(trackingPin, INPUT); // set trackingPin as INPUT
  pinMode(ledPin, OUTPUT); //set ledPin as OUTPUT
void loop()
  boolean val = digitalRead(trackingPin); // read the value of tracking module
  if(val == HIGH) //if it is HiGH
    digitalWrite(ledPin, LOW); //turn off the led
    digitalWrite(ledPin, HIGH); //turn on the led

Running Result

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; when it meets a white area, it outputs low and the LED lights up.


1.The black line should be wider than the IR track sensor.

2.The sensitivity of the infrared sensor is adjustable – you may adjust it by the potentiometer.