Go Down

Topic: Need help with 7 segment displays. (also, is this the right section for this?) (Read 2528 times) previous topic - next topic


I've done this part a little differently to handle the rollovers:
Code: [Select]

if (currentTime - oldTime > counter1)
if (units == 10)
 units = 0;
 if (tens == 10);
   tens = 0
   if (hundreds == 10)
       hundreds = 0
       thousands++ = 0;
       if (thousands == 10)
       thousands = 0;
       } // end thousands
     } // end hundreds
    }// end tens
    } // end ones
  } // end time increase check
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.


I'm really confused.

Yes so am I.

When you post code you have to post all of it so we can compile it and test it.
The code you posted will not compile because you have the line:-
Code: [Select]
settoDisp(keepTrack, keepTrack2);
And no where do you define the function. It is this function that probably has the error in it.



Sorry, now it just displays 8's.

Edit: I changed it so it actually displays the unit. They all turn on with 0 and then the units led turns on with zero and doesn't change.


You need to add some debug prints to see what is happening. I changed the end of your code to this:-
Code: [Select]
if (currentTime2 - oldTime2 > counter2){
        if (keepTrack == 1) {
          keepTrack2 = thousands;
        else if (keepTrack == 2) {
          keepTrack2 = hundreds;
        else if (keepTrack == 3) {
          keepTrack2 = tens;
        else if (keepTrack == 4) {
          keepTrack2 = units;
        else {
          keepTrack2 = 4;
        // settoDisp(keepTrack, keepTrack2);
        Serial.print(" -> ");

Having first done a serial begin in the setup.

If you run this you will find it stops after a few bursts of activity. You will also find that the variable keepTrack keeps getting more negative. You are not updating oldTime2 correctly, this should only be updated inside that if statement, can you think why?

Go Up