import wokwi

# Define GPIO pin numbers
TRIG_PIN = 2  # GPIO pin number for the ultrasonic sensor's trigger
ECHO_PIN = 3  # GPIO pin number for the ultrasonic sensor's echo
PUMP_PIN = 4  # GPIO pin number for the water pump
LED_PIN = 5   # GPIO pin number for the LED

# Initialize components
ultrasonic_sensor = wokwi.ultrasonic(TRIG_PIN, ECHO_PIN)
pump = wokwi.motor(PUMP_PIN)
led = wokwi.led(LED_PIN)

while True:
    # Measure distance
    distance = ultrasonic_sensor.distance

    if distance < 10:  # Adjust this threshold as needed
        # Water level is above the limit, turn on the pump and LED
        pump.speed = 255  # Full speed
        led.on()
    else:
        # Water level is below the limit, turn off the pump and LED
        pump.speed = 0
        led.off()


BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT