我有一个8位数的LED显示板,但我得到了奇怪的结果。第21行定义了哪些线段点亮,哪些显示被使用。因此[1,0,0,0,1,0,0,0]关闭第1和第5段,并点亮第4和第8个显示器(显示器的顺序为4,3,2,1,8,7,6,5)。因此,第24行列表中的第一个1将关闭小数点并点亮第四个显示屏。第5个1关闭底部区段并点亮第8个显示屏
我希望能够指定要使用的显示器以及要亮起/不亮起显示器的哪些部分
以下是Python 3代码:
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")
我找到了一些指南,但它们只用于驱动单个显示器或8个LED。有很多关于Arduino的指南,我已经试着转换了,但是我只是不断地遇到类似的问题,显示错误的数字
需要向电路板发送16位数据。前8位用于照亮特定段,随后的8位用于指示要使用的显示器
在下面更新的代码中,第8个(最右侧)显示屏将显示字母“A”
根据我为你的电路板找到的原理图,看起来要驱动8个LED,你需要一个类似的程序。其主要思想是led必须不断刷新以显示多个数字。每个换档周期只启用一个区段模式(尽管您可以使其显示在多个数字上,这肯定是一个不寻常的应用。)
我没有费心去试着让数字位置和片段位置都正确,这取决于你。此外,数字选择极性可能需要反转。但对代码的编辑应该会让您更接近:
相关问题 更多 >
编程相关推荐