def _pin_pulse(pin, initial_state=GPIO.LOW, pulse_width=PULSE_WIDTH_SEC):
# type: (int, bool, Union[int, float]) -> None
"""Sends one pulse to the specified pin.
The pin will be returned to the specified initial state after the pulse
Args:
pin: The pin to pulse.
initial_state: The negation of this will be used as the pulse.
Defaults to GPIO.LOW.
pulse_width: how long, in seconds, to pulse the pin.
Defaults to PULSE_WIDTH_SEC.
"""
GPIO.output(pin, not initial_state)
try:
time.sleep(pulse_width)
finally:
GPIO.output(pin, initial_state)
评论列表
文章目录