Timer on a KS0108 display


just wanted share timer code display in right lower corner.
good have if want keep track of time passed start in application.
will show, hh:mm:ss
i did found count 27 hours before goes 00:00:00 again, 27 hours timers enough people.
and yes, code far perfect works.
the time code found on forum, man created that.
to more informtion on used ks0108 library , set check:
http://www.arduino.cc/playground/code/glcdks0108

code clock math added before void setup
code: [select]

unsigned long current_millis_value = 0;
unsigned long previous_millis_value = 0;
unsigned long m = 0;
unsigned int seconds = 0;
unsigned int minutes = 0;
unsigned int hours = 0;


code clock math added in void loop
code: [select]

 current_millis_value = millis();
 m += current_millis_value - previous_millis_value;
 seconds += m / 1000;
 m = m % 1000;
 minutes += seconds / 60;
 seconds = seconds % 60;
 hours += minutes / 60;
 minutes = minutes % 60;
 hours = hours % 24;
 previous_millis_value = current_millis_value;


code displaying clock added in void loop
code: [select]

glcd.fillrect(110, 47, 14, 10, white);
 
 if (seconds < 10){
 glcd.gotoxy(117, 47);
 glcd.printnumber(seconds);
 glcd.gotoxy(110, 47);
 glcd.puts("0");
 }
 else {
 glcd.gotoxy(110, 47);
 glcd.printnumber(seconds);
 }
 
 glcd.gotoxy(108, 46);
 glcd.puts(":");
 
 glcd.fillrect(94, 47, 13, 10, white);
 
 if (minutes < 10){
 glcd.gotoxy(101, 47);
 glcd.printnumber(minutes);
 glcd.gotoxy(94, 47);
 glcd.puts("0");
 }
 else {
 glcd.gotoxy(94, 47);
 glcd.printnumber(minutes);
 }
 
 glcd.gotoxy(92, 46);
 glcd.puts(":");
 
 glcd.fillrect(78, 47, 13, 10, white);
 
 if (hours < 10){
 glcd.gotoxy(85, 47);
 glcd.printnumber(hours);
 glcd.gotoxy(78, 47);
 glcd.puts("0");
 }
 else {
 glcd.gotoxy(78, 47);
 glcd.printnumber(hours);
 }



Arduino Forum > Forum 2005-2010 (read only) > Software > Interfacing > Timer on a KS0108 display


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums