Skip to content

[Bug] Sensor's only works once. Hub needs restart to make them work again #456

Closed
@Vinz1911

Description

@Vinz1911

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingplatform: Powered UpIssues related to LEGO Powered Upsoftware: pybricks-micropythonIssues with Pybricks MicroPython firmware (or EV3 runtime)topic: sensorsIssues involving sensors

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions