I just started learning about arduino recently and I am currently trying to build a two digit count down timer 0 - 99
I ran into a little bit of trouble and I am hoping someone here can give me some guidance..
my problem is that I can't seem to get it to display the numbers corectly and I don't know what I am doing wrong, now the sequence of numbers that it displays is :
0,0,00,1,4,5,66 and it loops back from 1
Your code is written for two SEPARATE 7-segment displays, each driven by a separate shift register. That two-digit display is a 2x8 matrix. You have to drive it like a matrix.
no I didn't write it, I found it one some website..can't remember where...
I am new at arduino and electronics so any help is appreciated
Thanks for the help!
johnwasser:
Your code is written for two SEPARATE 7-segment displays, each driven by a separate shift register. That two-digit display is a 2x8 matrix. You have to drive it like a matrix
One important thing to learn about coding is that if you try to write the entire project first, and then go back and troubleshoot it, you're going to have a bad time.
You should get small portions of the code working first, and gradually build up to the final project. This is where Mike's suggestion of using the Serial communication to debug comes in handy; it allows you to test variable code and verify it's result before trying to pipe those result into more code that could also potentially screw the values up.
Since you want to drive two digits with two 595, you can wire each 595 to each 7-segment display and drive them statically. That requires two separate 7-segment displays and it will greatly simplify programming for you - no more multiplexing.
crsunu,
You need to wire it differently.
There are 2 common anodes, 1 for each digit.
There are 8 segment pins, shared between digits. These can come out of 1 shift register.
To get started, connect the 2 anode pins to arduino outputs. You will have to rewrite the code to shift out the segment info, turn on 1 anode, wait 5mS, turn it off, change the segment info, turn on the 2nd anodem wait 5mS, turn it off, repeat. Your eyes will see them as both being on.
Since the anodes will be driven by arduino pins, you will have to limit the amount of current supplied, to <=5mA/segment, with a current limiting resistor per segment.
Assuming you have the UltraRed LEDs, the resistor should be (5V-1.9V)/.005 = 620 ohm. Use that or higher to avoid damaging the pins driving the anodes.
void loop() {
for (int i = 0; i < 100 ; i++) {
// move code here to split into 1, 10s
// hang out for a bit to show the number:
int x = 0;
while (x<10000){
// shrink void DisplayNumber to only show 1 digit
turn off anode 2
DisplayNumber(ones);
turn on anode 1
delay(5);
turn off anode 1
Display(tens);
turn on anode 2
delay(5);
x=x+1;} //
} // next number
} // end loop
Using the while (x<10000) is kind of kludgy. Once you get the numbers working, visit Blink Without Display and use millis() to capture the time passing and turn the digits on/off based on elapsed time instead.
Make sense?
CrossRoads:
crsunu,
You need to wire it differently.
There are 2 common anodes, 1 for each digit.
There are 8 segment pins, shared between digits. These can come out of 1 shift register.
To get started, connect the 2 anode pins to arduino outputs. You will have to rewrite the code to shift out the segment info, turn on 1 anode, wait 5mS, turn it off, change the segment info, turn on the 2nd anodem wait 5mS, turn it off, repeat. Your eyes will see them as both being on.
Since the anodes will be driven by arduino pins, you will have to limit the amount of current supplied, to <=5mA/segment, with a current limiting resistor per segment.
Assuming you have the UltraRed LEDs, the resistor should be (5V-1.9V)/.005 = 620 ohm. Use that or higher to avoid damaging the pins driving the anodes
yes it makes perfect sense but I didn't want to use too many arduino outputs and thats why I used the two shift registers
No you have a display working at the moment do you not?
That is why you are seeing some numbers, you say you see the counts:-
Now it counts 0 1 2 3...9 00 11 22 33 44
This has nothing to do with driving the display as a matrix. It has to do with what numbers you are telling it to display.
You have been told how to go about finding this, you have even been pointed to a possible mistake in the code.
Now try and find that error. If you can't then post the code where you have attempted to fix it. Say what you see on the display and say what you expect.