from machine import Pin, Timer
from time import sleep
import machine
import utime
button = machine.Pin(7, machine.Pin.IN, machine.Pin.PULL_UP)
button2 = machine.Pin(0, machine.Pin.IN, machine.Pin.PULL_UP)
gp = [10,11,12,13]
patterns = [[1,0,0],
[0,1,0],
[2,1,0],
[1,2,0],
[2,0,0],
[0,2,0],
[3,0,0],
[0,3,0],
[2,3,0],
[3,2,0],
[1,3,0],
[3,1,0]]
led = [Pin(i, Pin.IN) for i in gp]
def reset_pins():
global led
led = [Pin(i, Pin.IN) for i in gp]
for i in led:
i.value(0)
def set_pins(high, low):
global led
reset_pins()
led[high] = Pin(gp[high], Pin.OUT)
led[low] = Pin(gp[low], Pin.OUT)
led[high].value(1)
led[low].value(0)
def light_led(led_num):
set_pins(patterns[led_num][0], patterns[led_num][1])
i = -1
prev_button_state = 1
prev_button2_state = 1
while True:
button_state = button.value()
button2_state = button2.value()
if (button_state == 0 and prev_button_state == 1):
i=i+1
light_led(i)
utime.sleep(0.3)
if (button2_state == 0 and prev_button2_state == 1):
i=i+2
light_led(i)
utime.sleep(0.3)
prev_button_state = button_state
prev_button2_state = button2_state
pico:GP0
pico:GP1
pico:GND.1
pico:GP2
pico:GP3
pico:GP4
pico:GP5
pico:GND.2
pico:GP6
pico:GP7
pico:GP8
pico:GP9
pico:GND.3
pico:GP10
pico:GP11
pico:GP12
pico:GP13
pico:GND.4
pico:GP14
pico:GP15
pico:GP16
pico:GP17
pico:GND.5
pico:GP18
pico:GP19
pico:GP20
pico:GP21
pico:GND.6
pico:GP22
pico:RUN
pico:GP26
pico:GP27
pico:GND.7
pico:GP28
pico:ADC_VREF
pico:3V3
pico:3V3_EN
pico:GND.8
pico:VSYS
pico:VBUS
btn1:1.l
btn1:2.l
btn1:1.r
btn1:2.r
btn2:1.l
btn2:2.l
btn2:1.r
btn2:2.r
led7:A
led7:C
led8:A
led8:C
led9:A
led9:C
led10:A
led10:C
led11:A
led11:C
led12:A
led12:C
r4:1
r4:2
r5:1
r5:2
r6:1
r6:2
led1:A
led1:C
led2:A
led2:C
led3:A
led3:C
led4:A
led4:C
led5:A
led5:C
led6:A
led6:C
r1:1
r1:2
led19:A
led19:C
led20:A
led20:C
led21:A
led21:C
led22:A
led22:C
led23:A
led23:C
led24:A
led24:C
led13:A
led13:C
led14:A
led14:C
led15:A
led15:C
led16:A
led16:C
led17:A
led17:C
led18:A
led18:C