from maqueen import * from microbit import * robot = Maqueen() front_sensor = robot.front_sensor dist = 10 while True: newdist = int(front_sensor.distance() / 10) if newdist != dist: dist = newdist # Show distance in decimeters print(str(dist) + "0cm") # print on console display.show(dist) # ... and on display sleep(100)