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

6. Raspberry Pi Pico

Data Reading

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

1. Quick Start

This tutorial explains how to use the PICO2 motherboard to read the digital information from an eight-channel grayscale tracking module and view the print results through the Shell window.

The hardware used in this tutorial is the PICO2 and eight-channel grayscale tracking module sold by Yabo. Refer to the wiring diagram below to connect the wires, then program the PICO2 to obtain the data. Modules other than Yabo's are for reference only.

2. Hardware Wiring

The PICO2's microUSB port requires a microUSB cable to connect to the USB port.

image-20251105144540335

Eight-channel grayscale tracking modulePICO2
5VVBUS
GNDGND
AD0GP2
AD1GP3
AD2GP4
OUTGP5

The standard cable for the eight-channel grayscale line-following 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

Find the code Grayscale_Read After opening the Thonny software and connecting the Raspberry Pi pico2, click the stop button on the far right of the top toolbar:

Then you can see the current firmware information of pico2 pop up in the message bar at the bottom, which means that the software has recognized the serial port:

If the message bar here shows that the serial port cannot be recognized, or if you are not familiar with basic operations, you need to consult the PICO2 motherboard documentation, find the tutorial on setting up the development environment (Python), and learn the relevant basic usage and firmware flashing. Flashing the firmware to the motherboard will enable serial port recognition:

After successfully recognizing the serial port and printing firmware information, click the green button to start running the script:

5

4. Phenomenon and Results

After running the program in Thonny, you can see that the Shell window at the bottom continuously prints the digital values ​​of the eight-channel grayscale tracking module. S1 corresponds to X1 on the module. When the X1 light is on, the value of S1 is 1.

image-20251105142410575

5. Code Explanation

xxxxxxxxxx
def _select_channel(self, channel):
    """
    Select the sensor channel
    """
    self.ad0.value((channel >> 0) & 0x01)
    self.ad1.value((channel >> 1) & 0x01)
    self.ad2.value((channel >> 2) & 0x01)
​
def _read_out_value(self):
    """
    Read the value from the OUT pin
    """
    return self.sensor_out.value()
​
def read_all(self):
    """
    Read all channels
    """
    values = []
    for i in range(self.channels):
        self._select_channel(i)
        time.sleep_us(50)
        values.append(self._read_out_value())
    return values
​
def read_single(self, channel):
    """
    Read a single channel
    """
    if channel >= self.channels:
        return 0
    self._select_channel(channel)
    time.sleep_us(50)
    return self._read_out_value()
​
def print_values(self):
    """
    Print all sensor values
    """
    values = self.read_all()
    for i, value in enumerate(values):
        print(f"[S{i+1}:{value}]", end=" ")
    print()
  • _select_channel: Selects the corresponding sensor channel via a control pin based on the passed channel number.
  • _read_out_value: Reads the digital output value of the currently selected sensor channel.
  • read_all: Iterates through and reads the current status of all 8 sensor channels.
  • read_single: Reads the current status of a single, specified sensor channel.
  • print_values: Retrieves the sensor values ​​for all channels and prints them in format to the console.

 

Arduino
MSPM0 Smart Car

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
QR Code

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文