Go Down

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

CrossRoads

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

if (currentTime - oldTime > counter1)
{
units++;
if (units == 10)
{
 units = 0;
 tens++;
 if (tens == 10);
 {
   tens = 0
   hundreds++;
   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. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Grumpy_Mike

Quote
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.


Grumpy_Mike


diodex

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.

Grumpy_Mike

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(keepTrack);
        Serial.print(" -> ");
        Serial.println(keepTrack2);
        keepTrack--;
}

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