/* LiquidCrystal Library - Hello World Demonstrates the use a 20x2 LCD display. This sketch prints "Hello World!" to the LCD and shows the time. Library originally added 18 Apr 2008 by David A. Mellis library modified 5 Jul 2009 by Limor Fried (http://www.ladyada.net) example added 9 Jul 2009 by Tom Igoe modified 22 Nov 2010 by Tom Igoe This example code is in the public domain. */ // Include the library code: #include // Initialize the library with the numbers of the interface pins // rs, enable, d0, d1, d2, d3, d4, d5, d6, d7 LiquidCrystal_mx300N lcd(12, 13, 4, 5, 6, 7, 8, 9, 10, 11); uint8_t rows = 2; uint8_t cols = 20; char cln = ' '; unsigned long startTime; unsigned long partTime; void setup() { // Set up the LCD's number of columns and rows: lcd.begin(cols, rows); // Print a message to the LCD. lcd.print("hello, world!"); delay(2000); startTime = ((((long)12 * 60) + 32) * 60 + 00); // initialise time // but would need to get real time from somewhere to make display useful lcd.clear(); lcd.setCursor(0, 1); lcd.print("The time is"); } void loop() { /* lcd.clear(); for(int i=0; i<8; i++) { lcd.print(char(i)); lcd.print(' '); } delay(5000); lcd.clear(); lcd.setBigfont(); for(int i=0; i<10; i++) { lcd.print(char('0'+char(i))); lcd.print(' '); } delay(10000); */ // Toggle hms separator (colon) //cln = char(' ') + char(5) - cln; cln = char(' ') + char(':') - cln; partTime = startTime + millis() / 1000; // wraps back to start after 50 days or so! // (time keeping accuracy dependant upon accuracy of Arduino timer) // Print each digit, starting at least significant // and shift partTime one digit lcd.setBigfont(); lcd.setCursor(19, 0); lcd.print(partTime % 10); // seconds partTime = partTime / 10; lcd.setCursor(18, 0); lcd.print(partTime % 6); // tens of seconds partTime = partTime / 6; lcd.setCursor(17, 0); lcd.print(cln); lcd.setCursor(16, 0); lcd.print(partTime % 10); // minutes partTime = partTime / 10; lcd.setCursor(15, 0); lcd.print(partTime % 6); // tens of minutes partTime = partTime / 6; lcd.setCursor(14, 0); lcd.print(cln); lcd.setCursor(13, 0); partTime = partTime % 24; lcd.print(partTime % 10); // hours lcd.setCursor(12, 0); partTime = partTime / 10; lcd.print(partTime % 6); // tens of hours partTime = partTime / 6; delay(492); // loop every half second or so // (delay doesn't affect time keeping, just colon flash rate) /* lcd.autoscroll(); lcd.setBigfont(); for (int i=0; i<1000; i++ ) { lcd.print(i % 10); delay(500); } */ /* lcd.clear(); lcd.clearBigfont(); lcd.setCursor(0,1); lcd.print("Today : "); lcd.setCursor(9,0); lcd.setBigfont(); lcd.print(10.0-random(200)/10); lcd.clearBigfont(); lcd.print(char(223)); lcd.print('C'); delay(1000); */ }