I thought I would try a Pico to power a number of led circuits to light a model. I have managed to get a set of leds to power on and another set to flash via a while true loop. I have tried to expand this to work off a momentary switch - as a test I tried this code (to switch on an led, pause, then switch on some flashing leds and then switch everything off :
Code: Select all
from machine import Pin
import utime
button = Pin(14, Pin.IN, Pin.PULL_DOWN)
deck_lights = Pin(13, Pin.OUT)
nav_lights = Pin(15, Pin.OUT)
def button_callback(pin):
# Switch on the deck lights
deck_lights.value(1)
utime.sleep(2)
i = 0
while i < 10:
nav_lights.value(0)
utime.sleep(1)
nav_lights.value(1)
utime.sleep(0.1)
i+=1
nav_lights.value(0)
utime.sleep(2)
deck_lights.value(0)
button.irq(button_callback, Pin.IRQ_FALLING)
Any help would be appreciated! Sorry, but I lost the code showing both buttons (but I'll recreate it and paste here if required)
Thanks,
Steve