Description
–
Related Tags
–
from time import sleep
from ptpma.components import PMAUltrasonicSensor, PMALed
ultrasonic_sensor = PMAUltrasonicSensor("D4")
red_led = PMALed("D2")
while True:
print(ultrasonic_sensor.distance)
sleep(0.1)
if ultrasonic_sensor.distance < 30:
red_led.on()
else:
red_led.off()
from ptpma.components import PMAUltrasonicSensor, PMALed
ultrasonic_sensor = PMAUltrasonicSensor("D4")
red_led = PMALed("D2")
while True:
print(ultrasonic_sensor.distance)
sleep(0.1)
if ultrasonic_sensor.distance < 30:
red_led.on()
else:
red_led.off()