Line Follower Module(5 channel)

From Wiki
Revision as of 09:48, 12 September 2017 by Root (Talk | contribs) (How to Use on Arduino)

Jump to: navigation, search

Introduction

5 channel line follower.png
5 channel line follower back.png
The TCRT5000 infrared photoelectric switch adopts a high transmit power infrared photodiode and a highly sensitive phototransistor. It works by applying the principle of objects' reflecting IR light – the light is emitted, then reflected, and sensed by the synchronous circuit. Then it determines whether there exists an object or not by the light intensity. It can easily identify black and white lines. In other words, the different conduction levels of the phototransistor when it passes over black and white lines can generate different output voltages. Therefore, all we need to do is to collect data by the AD converter on the Atmega328 and then send the data to the master control board via I2C communication.
This module is an infrared tracking sensor one that uses 5 TRT5000 sensors. 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.

How to Use on Raspberry Pi

Raspberry Pi line-following module
GND GND
5V VCC
SDA(GPIO2) SDA
SCL(GPIO3) SCL

How to Use on Arduino

Wiring

line-following module SunFounder uno Board
GND GND
VCC 5V
SDA A4
SCL A5

After the circuit is energized, the power indicator LED D0 will brighten.

Code

#include <Wire.h>

int count = 0; int raw_result[10]; int analog_result[5]; int high_byte; int low_byte; void setup() {

 Wire.begin();        // join i2c bus (address optional for master)
 Serial.begin(9600);  // start serial for output
 Serial.println("Ready");
 delay(1000);

} void loop() {

 Wire.requestFrom(0x11, 10);    // request 6 bytes from slave device #8
 while (Wire.available()) { // slave may send less than requested
   int c = Wire.read(); // receive a byte as character
   Serial.print(c, HEX);        // print the character
   Serial.print("  ");
   raw_result[count] = c;
   count += 1;
 }
 Serial.println(' ');
 count = 0;
 for (int i = 0; i < 5; i++) {
   high_byte = raw_result[i * 2] << 8;
   low_byte = raw_result[i * 2 + 1];
   analog_result[i] = high_byte + low_byte;
   Serial.print(analog_result[i]);
   Serial.print("  ");
 }
 Serial.println(' ');
 delay(500);

}

Configuration