Here's a project you can try if you have an Arduino Duemilanove and a compatible LCD Shield. Both boards I'm using is an Arduino knock-off and they're from DFRobot, a Chinese retailer specializing in sale of electronic and robotic components. You can find more of their products here:
http://www.dfrobot.com/. If you're in Malaysia, you can try out their distributor at
http://myduino.com/. They carry most of DFRobot's inventory, and also some of the original Arduino boards.
For this hack, I used the following:
1. A DFRduino Duemilanove (Arduino Compatible) 328 board
2. DFRobot LCD Shield for Aduino
To program the codes, I use the latest Arduino Software, ver 0021, which you can download here:
http://arduino.cc/en/Main/Software. This software allows you to write the script as well as compile the codes necessary for the Arduino to run.
Here are the codes I used:
#include <LiquidCrystal.h>
#include <DateTime.h>
#include <DateTimeStrings.h>
#define dt_SHORT_DAY_STRINGS
#define dt_SHORT_MONTH_STRINGS
// simple sketch to display a digital clock on an LCD
// see the LiquidCrystal documentation for more info on this
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
int backLight = 13; // pin 13 will control the backlight
void setup(){
pinMode(backLight, OUTPUT);
digitalWrite(backLight, HIGH); // turn backlight on. Replace 'HIGH' with 'LOW' to turn it off.
DateTime.sync(DateTime.makeTime(0, 44, 13, 16, 10, 2010)); // sec, min, hour, date, month, year // Replace this with the most current time
}
void loop(){
if(DateTime.available()) {
unsigned long prevtime = DateTime.now();
while( prevtime == DateTime.now() ) // wait for the second to rollover
;
DateTime.available(); //refresh the Date and time properties
digitalClockDisplay( ); // update digital clock
}
}
void printDigits(byte digits){
// utility function for digital clock display: prints preceding colon and leading 0
lcd.print(":");
if(digits < 10)
lcd.print('0');
lcd.print(digits,DEC);
}
void digitalClockDisplay(){
lcd.clear();
lcd.begin(16,2);
lcd.setCursor(3,0);
//lcd.print(DateTimeStrings.dayStr(DateTime.DayofWeek));
if(DateTime.Day <10)
lcd.print('0');
lcd.print(DateTime.Day,DEC);
lcd.print("/");
//lcd.print(DateTimeStrings.monthStr(DateTime.Month));
if(DateTime.Month <10)
lcd.print('0');
lcd.print(DateTime.Month,DEC);
lcd.print("/");
lcd.print((DateTime.Year,DEC)+2000);
//lcd.print(" ");
if(DateTime.Hour <10)
lcd.setCursor(5,1);
lcd.setCursor(4,1);
// digital clock display of current time
lcd.print(DateTime.Hour,DEC);
printDigits(DateTime.Minute);
printDigits(DateTime.Second);
}
You will need two additional libraries for it to work. They are the DateTime.h and DateTimeStrings.h. You can download them here:
http://www.arduino.cc/playground/uploads/Code/DateTime.zip. Just copy both the folders to the 'libraries' folder in your Arduino directory.
Once you have all that done, stack the LCD shield on the Arduino board (make sure the pins line up), plug in the USB cables to the board as well as to your PC, and hit Compile on the Arduino software. The codes will be uploaded and you shall be able to see the result on your LCD screen!
If all goes well, you should be able to see the following:
Note that the keypad on the LCD shield is not functional as I did not include any codes for them to respond to. That itself may be the next hack for me to try!
Bugs/Problems/Feedback/Comments? List them down in the comments and I'll try my best to help you out!