from machine import Pin
import time
time.sleep(0.1) # Wait for USB to become ready
#define PINs according to cabling
dataPIN = 22
latchPIN = 26
clockPIN = 27
#set pins to output PIN objects
dataPIN=Pin(dataPIN, Pin.OUT)
latchPIN=Pin(latchPIN, Pin.OUT)
clockPIN=Pin(clockPIN, Pin.OUT)
#define shift register update function
def shift_update(input,data,clock,latch):
#put latch down to start data sending
clock.value(0)
latch.value(0)
clock.value(1)
#load data in reverse order
for i in range(7, -1, -1):
clock.value(0)
data.value(int(input[i]))
clock.value(1)
#put latch up to store data on register
clock.value(0)
latch.value(1)
clock.value(1)
#main program, calling shift register function
bit_string="00001111"
S0 = Pin(9, mode=Pin.OUT)
S1 = Pin(8, mode=Pin.OUT)
S2 = Pin(7, mode=Pin.OUT)
S3 = Pin(6, mode=Pin.OUT)
M0 = Pin(21, mode=Pin.OUT)
M1 = Pin(20, mode=Pin.OUT)
M2 = Pin(19, mode=Pin.OUT)
M3 = Pin(18, mode=Pin.OUT)
M0.off()
M1.off()
M2.off()
M3.off()
S0.off()
S1.off()
S2.off()
S3.off()
muxAdd = [S0, S1, S2, S3]
print(muxAdd[0].value())
print(muxAdd[1].value())
print(muxAdd[2].value())
print(muxAdd[3].value())
while True:
for i in range (0, 4, 1):
muxAdd[i].on()
time.sleep(1)
muxAdd[i].off()
time.sleep(1)
Loading
cd74hc4067
cd74hc4067
Loading
cd74hc4067
cd74hc4067
Loading
cd74hc4067
cd74hc4067
Loading
cd74hc4067
cd74hc4067
Loading
cd74hc4067
cd74hc4067