from picozero import DistanceSensor, Button, RGBLED
from time import sleep
ds = DistanceSensor(echo=1, trigger=0, max_distance=400)
button = Button(15)
rgb = RGBLED(red=3, green=4, blue=5)
while True:
if button.is_pressed:
print('here')
while True:
print(ds.distance)
distCM = ds.distance * 100
print(distCM)
if distCM <= 50:
rgb.color = (255, 0, 0)
elif distCM > 50 and distCM <= 100:
rgb.color = (0, 255, 0)
elif distCM > 100:
rgb.color = (0, 0, 255)
sleep(0.1)