Arduino中的二进制移位寄存器操作
我正在为 Arduino 开发一个程序,该程序将数据发送到一些移位寄存器以控制大型点阵显示器。我需要滚动文本,这就是我遇到问题的地方。例如,假设显示屏显示“HI”。整个屏幕上的第一组数据是“10001 11111”。这将代表在第一阶段点亮的柱子。如果我把它们放在一起并添加一个空格,我会得到“10001011111”,我发现二进制数字可以通过除以 2 来移动一列。
例如“11111”/ 2 = 01111。下一个除法是 00111 ,然后是 00011 和 00001 等。问题是我将数据传递到两个单独的移位寄存器,每个数字一个。所以首先我发送“11111”,然后移入“10001”。当它们滚动时,数据需要从一个显示器传输到另一个显示器。下面是一个图表,旨在让您更清楚地理解这一点: 对于作品《HI》
BAD
H | I
10001 0 11111
01000 0 01111
00100 0 00111
00010 0 00011
00001 0 00001
00000 0 00000
我需要的
H | I
10001 0 11111
01000 1 01111
00100 0 10111
00010 0 01011
00001 0 00101
00000 1 00010
00000 0 10001
00000 0 01000
00000 0 00100
00000 0 00010
00000 0 00001
00000 0 00000
我真的已经尝试了我能想到的一切。解决办法是什么?
I am working on a program for Arduino that sends data to some shift registers to control a large dot-matrix display. I need the text to scroll, and this is where I run into problems. Let's say for example that the display is showing "HI". The first set of data along the entire screen would be "10001 11111". This will represent the columns that are lit in the first phase. If I put that together and add a space I get "10001011111" I have figured out that a number in binary can be shifted one column by dividing it by 2.
So for example "11111" / 2 = 01111. The next division is 00111, then 00011, and 00001, etc. The problem is that I am passing the data to two separate shift registers, one for each digit. So first I send "11111", and then I shift in "10001". When they are scrolling the data needs to transfer from one display to another. Below is a chart to try to make more sense of this:
For the work "HI"
BAD
H | I
10001 0 11111
01000 0 01111
00100 0 00111
00010 0 00011
00001 0 00001
00000 0 00000
What I need
H | I
10001 0 11111
01000 1 01111
00100 0 10111
00010 0 01011
00001 0 00101
00000 1 00010
00000 0 10001
00000 0 01000
00000 0 00100
00000 0 00010
00000 0 00001
00000 0 00000
I have really tried everything I can think of. What is the solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将 10001011111 移至第二列。
将 00000010001 移至第一个。
Shift 10001011111 into the second column.
Shift 00000010001 into the first.
如果您的线路适合用于存储数据的空间,您不能将整条线路放在那里并移动它吗?不要使用固定的中央分隔空间,而是将您的消息编码为您尝试显示的矩阵,而不是单个字母。
然后重复除以 2。
对所有其他行执行相同的操作,我打赌第二行将是
10001000100
并且右移除以 2 的效果是一样的。If your line will fit inside the space you have available to store the data, can't you just put the entire line there and shift it? Rather than using a fixed central divider space, encode your message not as individual letters but just as the matrix you are trying to display.
then repeatedly divide by 2.
Do the same thing on all the other lines, I bet the 2nd one will be
10001000100
and the right-shift divide by 2 works just the same.