yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
8-channel Grayscale Tracking Module📖
0. Precautions for use
  • Identifying Defective Solutions
1.About 8-channel tracking module
  • 8-channel grayscale module introduction
2.MCU data reading
  • 1.MSPM0G3507
  • 2.MSPM0G3519new
  • 3.STM32F103C8T6
  • 4.ESP32
  • 5.Arduino
  • 6. Raspberry Pi Pico
3.Car gray line tracking
  • 1. MSPM0 Smart Car
  • 2. STM32 development board for small car
  • 3. ESP32 wheeled car chassis V1
  • 4. Arduino Wheeled Car Chassis V2
  • 5. Raspberry Pi Pico Wheel Car Chassis V2
Download
  • Code
  • 3D Model File
  • Serial Port Assistant
Download ZIP

Welcome to 8-channel Grayscale Tracking Module repository

5.Arduino

Data Reading

Data Reading1. Quick Start2. Hardware Wiring3. Usage Method4. Observation and Results5. Code Explanation

1. Quick Start

This tutorial explains how to use the Arduino UNO motherboard to read the digital information from an eight-channel grayscale line-following module and print the results via a serial monitor.

The hardware used in this tutorial is an Arduino UNO and an eight-channel grayscale line-following module sold by Yabo. After connecting the wires according to the wiring diagram below, you can obtain the data by programming the Arduino UNO. Modules other than Yabo's are for reference only.

2. Hardware Wiring

The Arduino UNO's USB-B interface needs to be connected to the computer's USB port using a data cable.

image-20251108103928944

Eight-channel grayscale line-following moduleArduino UNO
5V5V
GNDGND
AD02
AD13
AD24
OUT5

The standard cable for the eight-channel grayscale tracking module sold by Yabo is an XH2.54 to 6-pin DuPont cable. One end of the XH2.54 ribbon cable should be connected to the eight-channel grayscale module, and the other end of the DuPont cable can be connected normally as shown in the picture above:

image-20251108182515884

3. Usage Method

  1. Open the Grayscale_Read.ino file in the Grayscale_Read folder using the Arduino IDE.
  2. Connect the Arduino UNO to the computer using a data cable.
  3. In the menu bar at the top left of the Arduino IDE, click the port selection box, and then select the serial port of the Arduino you are connecting.

image-20251108104609076

  1. If this is the first connection and there is a COM port number, but no Arduino model is specified, manually select the model.

image-20251108104722416

  1. Next, click the "Upload" button on the toolbar. The program will begin compiling and burning to the Arduino UNO.

image-20251108104753241

  1. After the upload is complete, click the "Serial Monitor" icon in the upper right corner of the toolbar.

image-20251108104826207

  1. In the upper right corner of the serial monitor window, ensure the baud rate is set to 115200.

4. Observation and Results

In the serial monitor, you can see the continuously printed digital values ​​of the eight-channel grayscale tracking module. X1 corresponds to X1 on the module; when the X1 indicator is lit, the corresponding value is 1.

image-20251108104914632

5. Code Explanation

x
//GPIO required for initializing the grayscale sensor
void Grayscale_Sensor_Init(void)
{
    pinMode(SENSOR_AD0_PIN, OUTPUT);
    pinMode(SENSOR_AD1_PIN, OUTPUT);
    pinMode(SENSOR_AD2_PIN, OUTPUT);
    pinMode(SENSOR_OUT_PIN, INPUT);
}
​
//Select sensor channel
static void _select_channel(uint8_t channel)
{
    SENSOR_AD0_WRITE((channel >> 0) & 0x01);
    SENSOR_AD1_WRITE((channel >> 1) & 0x01);
    SENSOR_AD2_WRITE((channel >> 2) & 0x01);
}
​
//Read the grayscale values of all 8 channels.
void Grayscale_Sensor_Read_All(uint16_t* sensor_values)
{
    uint8_t i;
    for (i = 0; i < GRAYSCALE_SENSOR_CHANNELS; i++)
    {
        _select_channel(i);
        delayMicroseconds(50);
        sensor_values[i] = Read_OUT_value();
    }
}
  • Grayscale_Sensor_Init: Called at the start of the program, sets the control pins (AD0-AD2) to output mode and the data pin (OUT) to input mode.
  • _select_channel: An internal function that selects one of the eight sensors by controlling the level combination of the three pins AD0, AD1, and AD2.
  • Grayscale_Sensor_Read_All: An external function that iterates through all 8 sensors by repeatedly calling _select_channel and reads their values ​​sequentially, storing them in an array.
ESP32
Raspberry Pi Pico

COMPANY

  • About us
  • Team Style
  • Blog

LEARNING & EXPLORATION

  • Tutorials
  • Edge AI hardware
  • Educational robots
  • Embedded intelligent hardware

WHERE TO BUY

  • Yahboom Online Store
  • Amazon
  • Alibaba
  • AliExpress
  • Mercado

TECHNOLOGY SUPPORT

  • Email: support@yahboom.com

BE A DISTRIBUTOR

  • Email: sales@yahboom.com
QR Code

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文