"""
INSTRUCTIONS
1. Finish defining the pins you will need to use for the 7 segment display
2. Make a total of 4 definitions, counting up to 3 starting from 0 (we're only doing 4 for sake of time)
3. Make a loop that resets to 0 once you are finished counting
4. Multiplex the signals by adding another 7 segment display on the breadboard with the same connection
and the ground pin going to the other side of the switch.
Notice that in a real case, you would have a transistor switching so you can control it digitally.
Bonus 1: Try to implement this off a physical circuit!
Bonus 2: If time permits, start a 2 digit counter! Note you will have to manually click very fast on the switch
to make the 7 segment displays seem like they're both on at the same time.
FUNCTIoffS YOU WILL NEED
pin.off()
pin.on()
sleep()
Note if your code is wrong, this website won't tell you whats wrong and you might not get an output.
"""
from machine import Pin
from time import sleep
# define all of the pins
# for your reference, pin0 = A, pin1 = B, etc
pinA = Pin(0, Pin.OUT)
pinB = Pin(1, Pin.OUT)
pinC = Pin(2, Pin.OUT)
pinD = Pin(3, Pin.OUT)
pinE = Pin(4, Pin.OUT)
pinF = Pin(5, Pin.OUT)
pinG = Pin(6, Pin.OUT)
def zero():
pinA.off()
pinB.off()
pinC.off()
pinD.off()
pinE.off()
pinF.off()
def one():
pinB.off()
pinC.off()
def two():
pinA.off()
pinB.off()
pinG.off()
pinE.off()
pinD.off()
def three():
pinA.off()
pinB.off()
pinG.off()
pinC.off()
pinD.off()
# turn everything off
def off():
pinA.on()
pinB.on()
pinC.on()
pinD.on()
pinE.on()
pinF.on()
pinG.on()
#what line can we put here to make all LEDs are off before we run the code?
off()
while True:
zero()
sleep(2)
off()
sleep(1)
one()
sleep(2)
off()
sleep(1)
two()
sleep(2)
off()
sleep(1)
three()
sleep(2)
off()
sleep(1)