Introduction
The infrared tracking sensor uses a TRT5000 sensor. The blue LED of TRT5000 is the emission tube and after electrified it emits infrared light invisible to human eye. The black part of the sensor is for receiving; the resistance of the resistor inside changes with the infrared light received.
Components
– 1 * SunFounder Uno board
– 1 * USB data cable
– 1 * Tracking sensor module
– 1 * 3-Pin anti-reverse cable
Experimental Principle
The IR emission tube of TCRT5000 sensor constantly emits infrared light. Since the black absorbs light, when the IR emission tube shines on a black surface, the reflected light is less and so less IR rays are received by the receiving tube. It indicates the resistance is large; then the comparator outputs high and the indicator LED goes out. Similarly, when it shines on a white surface, the reflected light becomes more. So the resistance of the receiving tube is lower; thus, the comparator outputs low and the indicator LED lights up.
In this experiment, use a tracking sensor module and the LED attached to pin 13 on the SunFounder Uno board to build a simple circuit. Since the LED has been attached to pin 13, connect the pin SIG to digital pin 7 of the Uno board. When the module gets on a black line, it output high and the corresponding LED stays off; when it meets a white line, it outputs low and the LED lights up. See the schematic diagram below.
Experimental Procedures
Step 1: Build the circuit
Step 2: Program (Please refer to the example code in LEARN -> Get Tutorial on our website)
Step 3: Compile
Step 4: Upload the sketch to SunFounder Uno board
Now, draw two black bold lines on the paper. If the rays emitted by the sensor encounter the black lines, the LED attached to pin 13 on the SunFounder Uno board will light up; otherwise, it is off.
Note: The black line should be wider than the TCRT5000 sensor.
Code
/******************************************* name:IR Tracking Sensor function:draw two black bold lines on the paper. If the rays emitted by the sensor encounter the black lines, the LED attached to pin 13 on the SunFounder Uno board will light up; otherwise, it is off. *****************************************/const int trackingPin = 7; //the tracking module attach to pin 7 const int ledPin = 13; //pin13 built-in ledvoid 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 } else { digitalWrite(ledPin, HIGH); //turn on the led } } |