Closed
Description
Describe the bug
I tried the following on the Inventor Hub with the ColorSensor and the UltraSonic Sensor:
Version: ('primehub', '3.1.0a3', 'v3.1.0a3-62-g51bdd097 on 2021-08-26')
Problem: Sensor's only works on first run of the script after stopping the script and run it again, the sensor's are not working.
After restart of the hub, the sensor's work again for the first run and then the problem appears again.
To reproduce
Steps to reproduce the behavior:
Just run this script, stop it and run it again:
from pybricks.pupdevices import ColorSensor, UltrasonicSensor
from pybricks.parameters import Port
from pybricks.tools import wait
from pybricks import version
# Initialize the sensor.
sensor = UltrasonicSensor(Port.C)
sensor.lights.on(100)
while True:
distance = sensor.distance()
print(distance)
wait(100)
Expected behavior
Sensor's work every time the script is running