Pi pico Larson Scanner part 3

Following Saturdays STEM Group meet up, Where Vance has rewirtten my scanner program so that it is more efficient. I have included the new code below. I have now made an improvement by adding a 10 segment LED display and getting this working my modifying the code that Vance helped me with.

The new code, using an array to store pin numbers is below

#flash on board pico led
# updated 1/7/2023 - working code
import machine 
import utime

# Vance
led_pins = [11,12,13,14,15]

#delay = input("Time Delay: ")

#bind leds gpip to variables

leds = []
for pin in led_pins:
    # Set to output
    leds.append(machine.Pin(pin, machine.Pin.OUT))
    # Turn the LED off
    leds[-1].value(0) #off
    
    
utime.sleep(3)

delay = 0.1 #set delay

while True:
    # Led sequence upwards
    for led in leds: 
        led.value(1)
        utime.sleep(delay)
        led.value(0)
   
    # Led sequence downwards
    for led in leds[-1:0:-1]:
        led.value(1)
        utime.sleep(delay)
        led.value(0)       

While my new code modification is here.

# use 10 led segment display
led_pins = [1,2,3,4,5,6,7,8,9,]

Which is just 1 line of actual code and a comment. The result of this is presented in the video below. I had to resolder the board with the LED display on as it had some joints missing.

Video

The video can be found here

Tags

#uPython,#RaspberryPiPico,#LarsonScanner,#PhysicalComputing


MastodonPeertubeQoto sign up

Donate using Liberapay