# Imports
from machine import Pin
import utime
import random
# pins
pou_data = Pin(13, Pin.OUT)
pou_latch = Pin(14, Pin.OUT)
pou_clock = Pin(15, Pin.OUT)
pou_save = Pin(0, Pin.OUT)
def Shift(input):
"""Shift
"""
global pou_data, pou_latch, pou_clock
# put latch down to start data sending
pou_clock.value(0)
pou_latch.value(0)
pou_clock.value(1)
# load in the data in reverse order
for i in range(len(input)):
pou_clock.value(0)
pou_data.value(int(input[i]))
pou_clock.value(1)
# pull latch up to store data on register
pou_clock.value(0)
pou_latch.value(1)
pou_clock.value(1)
#main program, calling shift register function
bit_strings = [
# Car off
"0000000000000000",
"0000000000000000",
# Unlocked (DRLs and Sidelights On)
"0001000000110000",
"0001000000110000",
# Ignition on (Dip beam on)
"0001100011111100",
"0001100011111100",
"0001100011111100",
"0001100011111100",
# Car running at night (Dip beam on)
"0001100011111100",
"0001100011111100",
"0001100011111100",
"0001100011111100",
# Car running at night (Main beam flashing)
"0001100111111110",
"0001100011111100",
"0001100011111100",
"0001100111111110",
"0001100011111100",
# Car is braking (Brake lights on)
"0101110011111100",
"0101110011111100",
"0101110011111100",
# Car running at night (Dip beam on)
"0001100011111100",
"0001100011111100",
# Car is Reversing (Reverse lights on)
"1011100011111100",
"1011100011111100",
# Car running at night in reverse (Dip beam on)
"1111110011111100",
"1111110011111100",
]
i = 0
while True:
if i == len(bit_strings):
i = 0
Shift(bit_strings[i])
i += 1
utime.sleep(0.5)