okay so one of my friends asked me to build him a count up timer for his wrist. he wants it to display: years, months, days, hours, minutes, seconds, and miliseconds on an lcd. it works fine when i write it for seconds(i'm testing it over serial monitor till the lcd comes in) but when i add milliseconds it takes about two minutes to reach a second. i'm thinking that my code is a little to laborious for the processor (arduino duemillenove) and it is taking to long to write it to the serial port. will someone look it over, also i haven't inserted the clear code for the lcd yet.
#include <Streaming.h>
#include <MsTimer2.h>
long month = 0;
long day = 0;
long year = 0;
long hour= 0;
long minute = 0;
long second = 0;
long millisecond = 0;
void setup()
{
//opens the serial port
Serial.begin(9600);
// sets the timer to run count every milisecond
MsTimer2::set(1, count);
MsTimer2::start();
}
void count()
{
//incriment the millisecond
++millisecond;
//tells the machine every year to reset month and add a year
if (month == 12)
{
month = 0;
++year;
}
//tells the machine every 30 days to reset day and add a month and yes i picked an arbitrary number for the month
else if (day == 30)
{
day = 0;
++month;
}
//tells the machine every 24 hours to reset hour and add a day
else if (hour == 24)
{
hour = 0;
day += 1;
}
//tells the machine every 60 minutes to reet minute and add an hour
else if (minute == 60){
minute = 0;
hour += 1;
}
//tells the machine every 60 seconds to reset second and add a minute
else if (second == 60){
second = 0;
minute += 1;
}
//tells the machine every 1000 miliseconds to reset milisecond to 0 and increase the second
else if (millisecond == 1000)
{
millisecond = 0;
second += 1;
}
// sends the obejects via the serial port using the Streaming library
Serial << "Years: " << year << " " << "Months: " << month << " " << "Days: " << day << " " << "Hours: " << hour << " " << "Minutes:" << minute << " " << "Seconds: " << second << " " << "Milliseconds: " << millisecond << endl;
}
void loop()
{
}
any ideas and criticism's welcome.