#
# Original: https://wokwi.com/projects/393849360067450881
#

import machine
import time
from utime import sleep

LED_COUNT = 9
LED_GPIO_START = 7

def Chaser(pins):
  delay = 0.2
  for pin in pins:
    pin.toggle()
    time.sleep(delay)
    pin.toggle()

  for pin in reversed(pins[0:len(pins) - 1]):
    pin.toggle()
    time.sleep(delay)
    pin.toggle()

def ToggleBits(pins, code):
  pinId = 0
  while code > 0:
    if code & 1:
      pins[pinId].toggle()
    code = code >> 1
    pinId = pinId + 1

time.sleep(0.1) # Wait for USB to become ready

print("Hello, Pi Pico!")

outputPins = []
for outputId in range(0, LED_COUNT):
  pin = machine.Pin(LED_GPIO_START + outputId, machine.Pin.OUT)
  outputPins.append(machine.Pin(LED_GPIO_START + outputId, machine.Pin.OUT))

Chaser(outputPins)

binaryCode = 12
if binaryCode == 0:
  for pin in outputPins:
    pin.off()
else:
  ToggleBits(outputPins, binaryCode)

# for outputId in range(0, LED_COUNT):
#   outputPins[outputId].toggle()
#   time.sleep(0.2)
#   outputPins[outputId].toggle()

# for outputId in range(LED_COUNT - 2, -1, -1):
#   outputPins[outputId].toggle()
#   time.sleep(0.2)
#   outputPins[outputId].toggle()
$abcdeabcde151015202530fghijfghij
$abcdeabcde151015202530354045505560fghijfghij
BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT
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
led1:A
led1:C
sw0:1
sw0:2
sw0:3
r1:1
r1:2
vcc1:VCC
gnd1:GND
led2:A
led2:C
sw1:1
sw1:2
sw1:3
r2:1
r2:2
led3:A
led3:C
sw2:1
sw2:2
sw2:3
r3:1
r3:2
led4:A
led4:C
sw3:1
sw3:2
sw3:3
r4:1
r4:2
led5:A
led5:C
r5:1
r5:2
led6:A
led6:C
r6:1
r6:2
led7:A
led7:C
r7:1
r7:2
led8:A
led8:C
r8:1
r8:2
led9:A
led9:C
r9:1
r9:2
led10:A
led10:C
r10:1
r10:2
led11:A
led11:C
r11:1
r11:2
led12:A
led12:C
r12:1
r12:2
gnd2:GND
btn0:1.l
btn0:2.l
btn0:1.r
btn0:2.r
btn1:1.l
btn1:2.l
btn1:1.r
btn1:2.r
btn2:1.l
btn2:2.l
btn2:1.r
btn2:2.r
vcc2:VCC
led13:A
led13:C
r13:1
r13:2