简体   繁体   中英

C++/Arduino 7digit doesn't show the 5 or 6

My problem is simple but I can't seem to fix it. I'm trying to get the basic numbers on my 7 digit display (0-9). I'm doing this using Binary code for the output. But somehow my display displays a 9 while it's actually the 5 that needs to be shown. Also if I want to display the 6 it displays a 8. Can someone help me? This are the binary codes I'm using.

0 = B00000011
1 = B10011111
2 = B01001011
3 = B00001101
4 = B10011001
5 = B01001001
6 = B01000001
7 = B00011111
8 = B00000001
9 = B00001001

Without access to the board you're using, it's difficult to pinpoint exactly what's going on, but I can make some educated guesses. Since you're learning, I'll be a bit longwinded (as is my nature anyway).

Here is a diagram of a 7 segment display, and its labels (side by side)

 --    aa
|  |  f  b
 --    gg
|  |  e  c
 --    dd

From your code, it appears that the wiring from your values to the display is as follows within a byte (bit numbers on top, X for unused), where 0 is ON and 1 is OFF:

76543210
abcdefgX

Based on that, the values used in your table should be:

0 = B00000011
1 = B10011111
2 = B00100101
3 = B00001101
4 = B10011001
5 = B01001001
6 = B01000001
7 = B00011111
8 = B00000001
9 = B00001001

Unless I've made a mistake, which is quite possible, I think your implementation of "2" is incorrect. This is further likely because the "2" value should have 5 "ON" bits, and there are only four 0's in your implementation.

Since you thought the 2 was correct, this implies that the wire for the 6th bit ("b" in the 7-segment diagram above) is loose or miswired (or possibly shorted to a different wire) because it is apparently still "ON" when a "1" is on that bit. This would cause a 6 to show as an 8, and a 5 to show as a 9, as you described.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM