Difference between revisions of "Line Follower Module(5 channel)"
(→Features) |
(→Connect the module to the I2C port of the Raspberry Pi:) |
||
(8 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
=Introduction= | =Introduction= | ||
This 5-Channel Line Follower module is an infrared tracking sensor that uses 5 TRT5000 sensors. The blue LED of the 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.<br> | This 5-Channel Line Follower module is an infrared tracking sensor that uses 5 TRT5000 sensors. The blue LED of the 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.<br> | ||
− | [[File: | + | [[File:5line.jpg]]<br> |
− | + | ||
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. | 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.<br> | 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.<br> | ||
Line 34: | Line 33: | ||
|} | |} | ||
After the circuit is energized, the power indicator LED D0 will brighten.<br> | After the circuit is energized, the power indicator LED D0 will brighten.<br> | ||
+ | |||
==Download the code:== | ==Download the code:== | ||
− | Log into your Raspberry Pi via a terminal. | + | ===Log into your Raspberry Pi via a terminal.=== |
git clone https://github.com/sunfounder/SunFounder_Line_Follower.git | git clone https://github.com/sunfounder/SunFounder_Line_Follower.git | ||
− | Go to the folder SunFounder_Line_Follower. | + | ===Go to the folder SunFounder_Line_Follower.=== |
cd SunFounder_Line_Follower/ | cd SunFounder_Line_Follower/ | ||
− | Run the Line_Follower.py file: | + | ===Run the Line_Follower.py file:=== |
python Line_Follower.py | python Line_Follower.py | ||
− | ==How to Use on Arduino | + | [[File:5 line-following module 1.png]]<br> |
− | == | + | Then you can see the data returned by the line follower module:<br> |
+ | [[File:5 line-following module 2.png]]<br> | ||
+ | If you encounter any problems about the I2C port, please refer to the solutions on the page: | ||
+ | http://wiki.sunfounder.cc/index.php?title=I2C_Configuration<br> | ||
+ | If you still cannot solve them, please post forums on our website: www.sunfounder.com/forum. <br> | ||
+ | |||
+ | =How to Use It on Arduino= | ||
+ | ==Connect the module to the I2C port of the Arduino Uno:== | ||
{| border="1" class="wikitable" | {| border="1" class="wikitable" | ||
|- | |- | ||
Line 61: | Line 68: | ||
|} | |} | ||
After the circuit is energized, the power indicator LED D0 will brighten. | After the circuit is energized, the power indicator LED D0 will brighten. | ||
− | == | + | ==Upload the test code:== |
#include <Wire.h> | #include <Wire.h> | ||
int count = 0; | int count = 0; | ||
Line 95: | Line 102: | ||
delay(500); | delay(500); | ||
} | } | ||
− | + | After the code is uploaded successfully, open Serial Monitor, select 9600 for the baud rate. Then you can see the data returned by the module on the window. <br> | |
− | + | [[File:5line a.png]]<br> |
Latest revision as of 03:05, 2 November 2017
Introduction
This 5-Channel Line Follower module is an infrared tracking sensor that uses 5 TRT5000 sensors. The blue LED of the 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.
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.
Features
1) Uses the MCU STM8S105C4 as the controller, and the TCRT5000 infrared photoelectric sensor on each of the 8 line-follower modules.
2) Adopts I2C ports which only occupies 4 pins of the MCU.
3) The sensor TRT5000 is highly sensitive with reliable performance.
4) With a RESET button on the board for resetting, and positioning holes on the board for easy assembly.
5) Supply Voltage: 5V.
6) A potentiometer is added to adjust sensitivity if the signal of the black lines is too weak to detect. Normally you don't need to adjust.
How to Use It on Raspberry Pi
Connect the module to the I2C port of the Raspberry Pi:
Raspberry Pi | line-following module |
---|---|
GND | GND |
5V | VCC |
SDA(GPIO2) | SDA |
SCL(GPIO3) | SCL |
After the circuit is energized, the power indicator LED D0 will brighten.
Download the code:
Log into your Raspberry Pi via a terminal.
git clone https://github.com/sunfounder/SunFounder_Line_Follower.git
Go to the folder SunFounder_Line_Follower.
cd SunFounder_Line_Follower/
Run the Line_Follower.py file:
python Line_Follower.py
Then you can see the data returned by the line follower module:
If you encounter any problems about the I2C port, please refer to the solutions on the page:
http://wiki.sunfounder.cc/index.php?title=I2C_Configuration
If you still cannot solve them, please post forums on our website: www.sunfounder.com/forum.
How to Use It on Arduino
Connect the module to the I2C port of the Arduino Uno:
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.
Upload the test 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); }
After the code is uploaded successfully, open Serial Monitor, select 9600 for the baud rate. Then you can see the data returned by the module on the window.