From here I just need to add an RLC, buttons, and a speaker. I’ll try integrating another component each weekend, or at least as i find time.
O, and I’m using a standard Hitachi HD44780 16×2 character LCD display.
// include LCD lib:
#include <LiquidCrystal.h>
//initialize time
int hr = 00, mn = 59, sc = 30;
// initialize pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
//define time formatter
String formatTime(int num){
if(num<10){ return(“0″+String(num)); }
else{ return(String(num)); }
}
void setup(){
// set display size
lcd.begin(16, 2);
// useing an empty line
lcd.print(“I’m Nathans new”);
lcd.setCursor(9,1);
lcd.print(“Clock!!”);
}
void loop(){
if(millis()%1000==0){
//incriment time
sc += 1;
//configure time
if(sc>=60){ mn+=1; sc=0; }
if(mn>=60){ hr+=1; mn=0; }
if(hr>=24){ hr=0; }
//print time
lcd.setCursor(0,1);
lcd.print(formatTime(hr)+”:”+formatTime(mn)+”:”+formatTime(sc));
}
}