#https://community.element14.com/challenges-projects/project14/b/blog/posts/project14-winners-announcement-7-segment-display-projects
#
# -scottiebabe 2022
from machine import Pin, mem32
import time
import random

# Configure GP26 as input with internal pull-up
pb = Pin(26,Pin.IN,Pin.PULL_UP)

# Configure GP14 - GP21 as outputs
PinBus = [ Pin(x,Pin.OUT) for x in range(14,22) ]

def BusWrite( pbus, v ):
    for i in range(len(pbus)):
        pbus[i].value( v & (1<<i))

# Seven segment LUT table for "thank you !"
# bit0 - segA, bit1 - segB,... bit7 - segDP
SGLUT = [ ~x for x in [0x78,0x74,0x77,0x54,0x76,0x00,0x6e,0x5c,0x1c, 0x00,0x86,0x00]]

def displaySevenSeg(v):
    BusWrite(PinBus,SGLUT[v])

BusWrite(PinBus,0xff)
while True:
    for i in range(len(SGLUT)):
        BusWrite(PinBus,SGLUT[i])
        time.sleep(1)

print("Thanks for being awesome !!!")
BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT