0

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
Thijs
  • 103
  • 1
  • 2
  • 11

1 Answers1

2

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.

Bob Miller
  • 603
  • 5
  • 12
  • It turned out that my shield wasn't properly connected.. But now I'm struggling with displaying 2 digits.. Like 10 or 11 etc. Can you also help me with that? – Thijs Mar 15 '17 at 09:05
  • That should likely be a different question separate from this one, because it's best to keep these questions narrow in focus. On your new question, I recommend adding more detail about the type of shield you're using, and the code you're trying to use to display the different digits. If you add a link to the follow-up question here, I'll take a look when I get a chance, though likely someone will answer before me :) – Bob Miller Mar 15 '17 at 15:03