Pages: 1 [2]   Go Down
Author Topic: Need help with 7 segment displays. (also, is this the right section for this?)  (Read 1281 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 446
Posts: 23871
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I've done this part a little differently to handle the rollovers:
Code:
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
« Last Edit: July 30, 2012, 03:28:51 pm by CrossRoads » Logged

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.

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 515
Posts: 31567
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
settoDisp(keepTrack, keepTrack2);
And no where do you define the function. It is this function that probably has the error in it.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here, sorry.

* pnpclock.ino (4.36 KB - downloaded 5 times.)
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 515
Posts: 31567
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
if (keepTrack = 1)
Missing an equals sign here?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: August 03, 2012, 07:36:47 pm by diodex » Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 515
Posts: 31567
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You need to add some debug prints to see what is happening. I changed the end of your code to this:-
Code:
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?
Logged

Pages: 1 [2]   Go Up
Jump to: