Line Sensor

Detect the edge white line, using reflected light.

The line sensors return a value that represents the amount of reflected light read into the sensor. If the sensor is over the white line it will reflect more light to when it is over the black surface.

The line sensors are Analog sensors, that is the Controller will convert the sensor's analog voltage value into a digital number. The sumo board only has 4 ports that are capable of doing this: AC1, AC2, AC3 and AC5.

Experimentation is needed to work out the best value to use to detect the white lines.

import time
import board
import analogio

AC1 = analogio.AnalogIn(board.AC1)

while True:
    #read the value of the sensor. White will be higher than black - experiment
    print("AC1:",AC1.value)
    time.sleep(0.1)

Last updated