from picozero import DistanceSensor, LED, Button, RGBLED, PWMBuzzer
from time import sleep
ds = DistanceSensor(echo=28, trigger=27, max_distance=4)
led = LED(14)
button = Button(18)
rgb = RGBLED(red=2, green=1, blue=0)
#Ultrasonic Sensor will be turned around for actual circuit
while True:
if not(ValueError):
print('meters: ' + str(ds.distance))
sleep(0.1)
print('centimeters: ' + str(ds.distance * 100))
sleep(1)
if ds.distance <= 0.5:
print("BAD")
rgb.color = (255,0,0)
elif ds.distance > 0.51 and ds.distance <= 2:
print("eh")
rgb.color = (0, 255, 0)
else:
rgb.color = (0, 0, 255)
led.off()
else:
led.on()