step.wait_for_digital

Classes

WaitForDigital

Block until a digital sensor reads the desired state.

Module Contents

class step.wait_for_digital.WaitForDigital(sensor: raccoon.hal.DigitalSensor, pressed: bool = True)

Bases: step.base.Step

Block until a digital sensor reads the desired state.

Polls the sensor at 50 Hz and resumes execution once the reading matches the expected value. Useful for waiting until a bumper is pressed, a limit switch is triggered, or an external signal arrives.

Parameters:
  • sensor – The DigitalSensor instance to poll.

  • pressed – The target state to wait for. True (default) waits until the sensor reads high; False waits until it reads low.

Example:

from raccoon.step import wait_for_digital
from raccoon.hal import DigitalSensor

bumper = DigitalSensor(0)

# Wait until bumper is pressed
wait_for_digital(bumper)

# Wait until bumper is released
wait_for_digital(bumper, pressed=False)