Hi Robert, I'm stuck on the time/millis. I still can't get the timer to count accurately and I know I haven't put the code in right??

I have tried numerous ways and looked at other codes but can't figure out what I'm doing wrong.

Here's what I have;

`unsigned long currentmillis = 0;`

unsigned long previousmillis = 0;

unsigned long interval = 10;

int latchpin = 8; // connect to pin 12 on the 74HC595

int clockpin = 12; // connect to pin 11 on the 74HC595

int datapin = 11; // connect to pin 14 on the 74HC595

float b = 0;

int c = 0;

float d = 0;

int e = 0;

float f = 0;

int g = 0;

float h = 0;

int i = 0;

float j = 0;

int k = 0;

float l = 0;

int m = 0;

int hundredths1;

int seconds;

int minutes;

int hundredths;

int segdisp[10] = {

63,6,91,79,102,109,125,7,127,111 }; //segment references using 74HC595 Shift Registers

void setup()

{

pinMode(latchpin, OUTPUT);

pinMode(clockpin, OUTPUT);

pinMode(datapin, OUTPUT);

}

void loop()

{

currentmillis = millis(); // read the time.

if (currentmillis - previousmillis >= interval) // 10 milliseconds have gone by

{ previousmillis = currentmillis; // save the time for the next comparison

hundredths = hundredths +1;

}

{

// Counts up to 101 only!

for (int hundredths=0; hundredths<101; hundredths++)

{

digitalWrite(latchpin, LOW);

shiftOut(datapin, clockpin, MSBFIRST, 0); // clears the left display

shiftOut(datapin, clockpin, MSBFIRST, 0); // clears the left display

shiftOut(datapin, clockpin, MSBFIRST, 0); // clears the left display

shiftOut(datapin, clockpin, MSBFIRST, 0); // clears the left display

shiftOut(datapin, clockpin, MSBFIRST, 0); // clears the left display

shiftOut(datapin, clockpin, MSBFIRST, 0); // clears the left display

digitalWrite(latchpin, HIGH);

if (hundredths<1)

{

digitalWrite(latchpin, LOW);

shiftOut(datapin, clockpin, MSBFIRST, segdisp[hundredths]); // sends the digit down the serial path

shiftOut(datapin, clockpin, MSBFIRST, 0); // sends a blank down the serial path to push the digit to the right

shiftOut(datapin, clockpin, MSBFIRST, 0); // sends a blank down the serial path to push the digit to the right

shiftOut(datapin, clockpin, MSBFIRST, 0); // sends a blank down the serial path to push the digit to the right

digitalWrite(latchpin, HIGH);

}

else if (hundredths>=1)

//------------------------------ Hundredths below

{

d=hundredths%10; // find the remainder of dividing hundredths by 10, this will be the right-hand digit

c=int(d); // make it an integer, c is the right hand digit

b=hundredths/10; // divide hundredths by 10 - the whole number value will be the left-hand digit

e = int(b); // e is the left hand digit

//------------------------------ Ten of Seconds (60) below

if( hundredths == 100) {

c=0; // clear the hundredths digit

e=0; // clear the hundredths digit

hundredths=0; // reset the timer

seconds++; // add 1 second to "seconds"

f=seconds%10; // float the %

g=int (f); // print the % first "seconds" digit

h=seconds/10; // divid the seconds by 10 to get the tens of seconds

i = int (h); // print the tens of seconds digit

}

//------------------------------ Minutes (60) below

if( seconds == 60) {

g=0; // clear the "seconds" digit

i=0; // clear the "tens" of seconds digit

seconds=0; // reset the seconds

minutes++; // add 1 minute to "minutes"

j=minutes%10; // float the %

k=int (j); // print the % first "minute" digit

l=minutes/10; // divid the minutes by 10 to get the tens of minutes

m = int (l); // print the tens of minutes digit

}

//------------------------------

if( minutes == 60) {

k=0; // clear the "minutes" digit

m=0; // clear the "tens" of minutes digit

minutes=0; // reset the minutes

}

digitalWrite(latchpin, LOW); // send the digits down to the shift registers!

shiftOut(datapin, clockpin, MSBFIRST, segdisp[c]); // print the % first "hundredths" digit

shiftOut(datapin, clockpin, MSBFIRST, segdisp[e]); // print the tens of hundredths digit

shiftOut(datapin, clockpin, MSBFIRST, segdisp[g]); // print the % first "seconds" digit

shiftOut(datapin, clockpin, MSBFIRST, segdisp[i]); // print the tens of seconds digit

shiftOut(datapin, clockpin, MSBFIRST, segdisp[k]); // print the % first "minute" digit

shiftOut(datapin, clockpin, MSBFIRST, segdisp[m]); // print the tens of minutes digit

digitalWrite(latchpin, HIGH);

}

delay(10);

}}}

Can you see what is wrong?? I just want to get it counting accurately before adding buttons etc. It's roughly 2 seconds per minute out.

Cheers

Warren