Distance Sensors

Fast Digital Distance Sensors

The distance sensors that are provided are digital distance sensors. These do not provide a distance to an object, they just provide you with a true or false value regarding the space that is in front of the sensor. It either detects and object, or it does not.

The distance to an object is not that important in sumo, it's more important too quickly know if an opponent is near. By using digital sensors, our main code does not have to do any processing or waiting to work out if an opponent is near. We just need to check to see if the sensor is returning a value.

Look for the red LED on the back of the sensor, it will light up if an object is detected. Some sensors are set for 50cm, others are set for 25cm.

These digital sensors can be used on any port of the Sumo board.

import time
import board
import digitalio


DCB1 = digitalio.DigitalInOut(board.DCB1)
DCB1.direction = digitalio.Direction.INPUT


while True:
    #write the value of the sensor - look for the red LED on the sensor 
    print("DCB1:",DCB1.value)
    #small delay in the loop
    time.sleep(0.1)

Last updated