USER MANUAL SERIAL IR SENSOR ARRAY5 25mm (Serial Communication Based Automatic Line Position Detection Sensor using 5 TCRT5000 IR sensors) Description: You can now build a line follower robot without writing any line detection code and using only 2 digital pins of your arduino. This Line detection sensor not only senses black and white color but also calculates the line position all by itself using an on-board microcontroller and 5 infrared sensors. Line position can easily be obtained from it with serial communication. The built-in auto calibration method enables this sensor to detect line position on any typical surface instantly only by pushing a single button. An onboard white-black toggle switch gives you the option to detect both white line on black surface OR black line on white surface. There s Line indicating LEDs corresponding to each of the 5 Infrared sensors to ease your code debugging and let you know whether the calibration is okay or not. It gives a line position value of 1 when the line is beneath the leftmost sensor and 99 when the line is beneath the rightmost sensor and the value changes smoothly between this range. The precision is almost less than 1 millimeter. If that s not enough for you, here comes more. It can detect left sharp turn, right sharp turn, line intersection and line discontinuity all by itself. Corresponding signals are sent via serial (View value interpretation table in the user manual). You can also obtain the ADC values of individual sensors as well as their calibrated values. The sensor can detect line of any thickness (at least 1cm), but works best for a 25 mm or 1 inch thick line.
Specifications: Calculates the line position using 5 TCRT5000 IR Sensors and an on-board microcontroller. Serial communication: only 2 pins of your arduino is required to interface this sensor. Baud rate is 4800. Can detect a total of 100 line positions over the range covered by 5 IR sensors. Can detect left sharp turn, right sharp turn, line intersection and line discontinuity automatically. Super easy Auto calibration option using a single push button. Onboard white-black toggle switch to detect either white line on black surface OR black line on white surface. Recommended operational height from ground 3mm-20mm. (height of IR sensors tip, not the PCB). Operational voltage: 5 Volt. Design optimized to read a 25mm or 1inch thick line. Value interpretation table: Send to Sensor Sensor Reply L Meaning (Considering left & right by looking at the line follower robot from its front side) 1-99 Line Position, 50 for Midpoint 0 Line missed from left side, take sharp left turn 100 Line missed from right side, take sharp right turn 150 Line Intersection 200 Line Discontinuity (Line vanishes from center) 1 0-1023 ADC Value of sensor 1 (Leftmost) 2 0-1023 ADC Value of sensor 2 3 0-1023 ADC Value of sensor 3 4 0-1023 ADC Value of sensor 4 5 0-1023 ADC Value of sensor 5 (Rightmost) A 0-10 Calibrated Value of sensor 1 B 0-10 Calibrated Value of sensor 2 C 0-10 Calibrated Value of sensor 3 D 0-10 Calibrated Value of sensor 4 E 0-10 Calibrated Value of sensor 5 200 0 100 1-99
Connect to arduino: Using male to female jumper wires, connect the Sensor pins to your arduino. Sensor Pin Arduino Pin 5V 5V GND GND TX 10 RX 11 Calibration: 1. Connect the sensor to arduino. Make sure that the height of sensor from ground remains constant during and after calibration. Otherwise, it may give you wrong reading. It s recommended to attach the sensor to your robot before calibration. 2. Turn on the power switch to the > direction. The LEDs will blink. 3. Press the Calibration button and All LEDs will turn on. Now you have 5 seconds to put your robot/sensor on the ground over the Line/Track, before the calibration process begins (indicated by LED ripple effect). You need to make sure that the calibration doesn t start when the sensor is not over ground because that would result in wrong calibration. It s recommended to push the calibration button without taking the robot up from ground. It should be easy to do as we have placed that button at a corner of the PCB. 4. Move the sensor (with your robot) left and right so that the line comes under each TCRT5000 IR sensor at least once. Do this until LED ripple effect (calibration) ends. 5. Your sensor is now calibrated. Toggle the W-B switch to W if you intend to sense a white line on black surface or to B for a black line on white surface. When the line come beneath an IR sensor, the corresponding LED will turn on. 6. Calibration values are saved in the EEPROM of on-board microcontroller so they remain unchanged if you disconnect the power or turn the power switch off. That means, you just have to calibrate once for a particular arena/surface. Next time when you power the sensor up, it s already calibrated!! Calibration has to be done again only when you want to use the sensor for a different arena/surface. 7. It s not needed to calibrate right after powering up the sensor array. Calibration can be done any time. The sensor remembers the latest calibration. Sample test code: #include <SoftwareSerial.h> SoftwareSerial myserial(10, 11); int value,temp;
void setup() Serial.begin(57600); myserial.begin(4800);//default communication speed of the sensor void loop() myserial.write('l'); //change this to 1,2,3,4 or 5 to get individual sensor reading temp=myserial.read(); // temporary value if((temp<=200)&&(temp>=0)) value=temp; // sort from garbage value Serial.println(value); delay(3); //to avoid garbage value while using softwareserial Sample line following robot code using this Sensor: #include <SoftwareSerial.h> //don t use Serial0. Use softserial or Serial 1-3 (Arduino Mega) SoftwareSerial myserial(10, 11); boolean debugging = false; /*change to true to see sensor values in serial monitor*/ int value,temp; // your variables // void setup() Serial.begin(57600); myserial.begin(4800);// default communication speed of the sensor void loop()
myserial.write('l'); temp=myserial.read(); if((temp<=200)&&(temp>=0)) value=temp; delay(3); // needed to avoid garbage value while using softwareserial if(debugging==true)serial.println(value); if(value==150) gostraight(); // go straight at line intersection else if(value==0) sharpleftturn(); // line missed from left corner else if(value==100) sharprightturn(); // line missed from right corner else Linefollow(); // follow line using value from sensor void gostraight()/* your code*/ void sharpleftturn()/* your code*/ void sharprightturn()/* your code*/ void Linefollow()/* your code*/ Test code for Arduino Mega users: You can go for the faster hardware serial (Serial 1, 2 or 3) if you are using an arduino mega board. The following test code is for the sensors TX pin connected to RX1 and sensors RX pin connected to TX1 of arduino mega. int value,temp; void setup() Serial.begin(57600); Serial1.begin(4800); void loop()
Serial1.write('L'); while (Serial1.available()) temp=serial1.read(); if((temp<=200)&&(temp>=0)) value =temp; Serial.println(value); User Access for Development: The code of the on-board microcontroller can be changed using our avr programmer. But, you can always go back to the default state. Get the default.hex file from the document section of the product page. The SPI programming pins are marked in the sensor just as it is in our avr programmer. The onboard microcontroller is an Atmega8 running on 8 MHz internal clock. Serial IR Array5 MCU pin Connections Atmega8 pin Sensor Array Component VCC, AVCC 5V GND GND RESET RST PB1 LED1 PB2 LED2 PB3 LED3/MOSI PB4 LED4/MISO PB5 LED5/SCK PD0 RX PD1 TX PD3 CALIBRATION BUTTON PD4 W-B SWITCH PC4 SENSOR 1 SIGNAL PC3 SENSOR 2 SIGNAL PC2 SENSOR 3 SIGNAL PC1 SENSOR 4 SIGNAL PC0 SENSOR 5 SIGNAL