RGB line follower sensor module, which is idesigned specifically for line-following car matches, has 4 RGB supplement lamps and 4 light-sensitive receivers. The module applies to line following for either light-colored tracks on dark backgrounds, or dark tracks on light-colored backgrounds. All kinds of RGB line following modules are applicable, as long as the grey scale of the chromatic aberration between the background and the track is higher than the threshold (the higher the chromatic aberration, the better the line following performance). The module is characterized by fast detection, field learning function through keys and excellent adaptability. A blue-white labeled interface is equipped, indicating that it is a dual-digital, I2C interface that needs to be connected to the mainboard with a blue-white marking interface.
● Operating voltage: 5V DC
● Operating temperature: 0 ºC~70 ºC
● Detection height: it is suggested that the sensor is 5mm~15mm from the track, depending on material of the track and illumination.
● Signal mode: I2C communication (corresponding to the blue-white label)
● Dimensions: 48 x 72 x 26.5 mm (LxWxH)
● Arduino IDE programmable, with runtime library to simplify programming;
● Four LEDs for feedback of line-following and learning of new surroundings;
● RJ25 interface for convenient connection;
● Suitable for metal parts of Makeblock DIY platform: the white area on the module is the reference area in contact with metal beams;
● Modularized installation, compatible with LEGO;
● Equipped with interfaces compatible with most Arduino control boards;
● Field learning function: identifying and recording background of the field and color of the route;
● Supporting eeprom storage: data learned will be stored in eeprom, preventing data loss in case of power failure;
● Colors of RGB supplement lamps switchable: currently 3 colors switchable (read, green and blue), by pressing the switching key for 2 seconds;
● Sensitivity of line-following is adjustable;
● Reverse polarity protection, protecting IC in case of reverse polarity;
● Up to 4 line following sensors available on one main board.
Definitions of Pins
The RGB line follower module has a 6-pin interface, each pin has the function below:
|1||SDA||I2C data interface|
|2||SCL||I2C clock interface|
|5||S2||I2C address assignment port|
|6||S1||2C address assignment port|
● RJ25 Connection
Since the RGB line sensor module interface is blue-white, when using the RJ25 interface, it needs to be connected to the interface with the blue and white interfaces on the main control board. Taking Makeblock MegaPi as an example, you can connect to interfaces 5, 6, 7, and 8, as shown in the following figure:
● Connection with Dupont line
When using a DuPont cable to connect to the Arduino Uno mainboard, the A0 pin of the module needs to be connected to the ANALOG port as shown below:
In case of any change to the field, the surroundings or location where the RGB sensor is installed, it is suggested to start learning again. The data learned will be stored in eeprom, avoiding data loss in case of power failure. The learning process includes 4 steps:：
1. Adjusting colors of supplement lamps: select suitable colors of the supplement lamps by long pressing the switching key according to colors of the field background and the line.
2. Learning color of the background: install the RGB sensor in position, face the 4 RGB lamps right against the background, and click the key to make the 4 LEDs flash slowly. Learning will finish in 2~3 seconds, upon which the LEDs will stop flashing.
3. Learning color of the track: install the RGB sensor in position, make the 4 RGB lights right against the track, and double-click the key to make the 4 LEDs flashing slowly. Learning will finish in 2~3 seconds, upon which the LEDs will stop flashing.
4. Test and confirmation: keep the module in position, and adjust locations of the 4 sensors, to make sure they can detect colors of the background and the line properly. When detecting the background, LED of corresponding sensor will be on; and when detecting the line, the corresponding LED will be off.
● Arduino Programming
When conducting Arduino programming, Makeblock-Library-master shall be called to control the RGB line follower sensor.
Two enhanced 180-encoded motors are used for line-following control. Source files “MeRGBLineFollower” and “MeEnhanceEncoderOnBoard” must be included in the root directory of project file, as follows:
“MeRGBLineFollower180motorAuriga.ino” is an example of line following, based on Auriga control board, with 180-encoded motor as chassis. The following codes are used:
The following is an example of line following based on Auriga control board, with 180-encoded motor as the chassis:
The following is an example of line following based on mCore control board, with TT motor as the chassis:
The RGB line following sensor has 4 pairs of RGB transmitters and light-sensitive receivers, as shown in the figure below:
When RGB passes through different color backgrounds, the light-sensitive receivers converts the received light information into electrical signals, and outputs specific values from the analog ports after passing through the amplifier. The software then uses the analog values of the four light-sensitive receivers as a fusion algorithm to finally calculate the deviation of the position of the output sensor module from the track. The user can directly use this offset to control the rotation speed of the left and right two motors。