I have an 8-digit LED display board, but I'm getting odd results. Line 21 defines which segments are lit AND which displays are used. So [1,0,0,0,1,0,0,0] turns off the 1st and 5th segments and lights the 4th and 8th displays (displays are in the order 4, 3, 2, 1, 8, 7, 6, 5). So the first 1 in the list on Line 24 turns off the decimal point and illuminates the fourth display. The 5th 1 turns off the bottom segment and illuminates the eighth display.
What I would like is to be able to specify which display to use and which segments of that display to light / unlight.
Here is the Python 3 code:
import RPi.GPIO as IO
import time
# Ignore warnings
IO.setwarnings(False)
# Set pinouts
dataPin = 11
latchPin = 15
clockPin = 13
IO.setmode (IO.BOARD)
IO.setup(dataPin, IO.OUT)
IO.setup(clockPin, IO.OUT)
IO.setup(latchPin, IO.OUT)
# 7-segment displays are in the following
# order: 4 3 2 1 8 7 6 5
# Segments to light (0 = on / 1 = off)
segsLit = [1,0,0,0,1,0,0,0] # Line 21
# Iterate through 7-seg displays
for j in range(8):
IO.output(latchPin, 0)
# Iterate through list1 to light segments
for i in range(8):
IO.output(clockPin, 0)
IO.output(dataPin, segsLit[i])
IO.output(clockPin, 1)
IO.output(latchPin, 1)
IO.cleanup()
print("Done")
I've found a couple of guides, but they are for driving only a single display or just 8 LEDs. There are lots of guides for the Arduino, which I've tried to convert, but I just keep getting similar issues with the wrong digits displaying.