User Manual

100
# segCode =
[0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e]
# Shift the data to 74HC595
def hc595_shift(dat):
for bit in range(0, 8):
GPIO.output(SDI, 0x80 & (dat << bit))
GPIO.output(SRCLK, GPIO.HIGH)
time.sleep(0.001)
GPIO.output(SRCLK, GPIO.LOW)
GPIO.output(RCLK, GPIO.HIGH)
time.sleep(0.001)
GPIO.output(RCLK, GPIO.LOW)
for code in segCode: # Input item in segCode list to hc595_shift()function, to display
the character.
hc595_shift(code)
If you want to display a number, use the hc595_shift() function, segCode list and decimal
value x in the sketch:
hc595_shift(segCode[x]) # x is a number needs to be displayed ranging from 0~15, and it
will be coverted and displayed by 0~F in hexadecimal.
Note: The hexadecimal format of number 0~15 are (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F).
SunFounder