Arduino character LCD code example.
/* Demonstrates the use a 2x16 OLED display. The Liquid Crystal library works with all LCD displays that are compatible with the Hitachi HD44780 driver. This sketch prints to the OLED and shows the time since last reset The circuit: * OLED RS pin to digital pin 12 * OLED Enable pin to digital pin 11 * OLED D4 pin to digital pin 5 * OLED D5 pin to digital pin 4 * OLED D6 pin to digital pin 3 * OLED D7 pin to digital pin 2 * OLED R/W pin to ground */ // include the library code: #include <LiquidCrystal.h> #include <Time.h> #include <Wire.h> // initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { setTime(15,36,30,14,5,2013); lcd.begin(16, 2); delay(100); // wait for 1/10 second } void loop() { digitalClockDisplay(); delay(1000); } void digitalClockDisplay(){ // digital clock display of the time lcd.setCursor(2, 0); delay(10); // wait for 1/10 second lcd.print(hourFormat12()); printDigits(minute()); printDigits(second()); lcd.print(" "); if(isAM()){lcd.print("am");} else{lcd.print("pm");} lcd.setCursor(0, 1); printDay(); printMonth(); lcd.print(day()); lcd.print(" "); lcd.print(year()); } void printDigits(int digits){ // utility function for digital clock display: prints preceding colon and leading 0 lcd.print(":"); if(digits < 10) lcd.print('0'); lcd.print(digits); } void printDay(){ int day; day = weekday(); if(day == 1){lcd.print("Sun, ");} if(day == 2){lcd.print("Mon, ");} if(day == 3){lcd.print("Tue, ");} if(day == 4){lcd.print("Wed, ");} if(day == 5){lcd.print("Thu, ");} if(day == 6){lcd.print("Fri, ");} if(day == 7){lcd.print("Sat, ");} } void printMonth(){ int mon; mon = month(); if(mon == 1){lcd.print("Jan ");} if(mon == 2){lcd.print("Feb ");} if(mon == 3){lcd.print("Mar ");} if(mon == 4){lcd.print("Apr ");} if(mon == 5){lcd.print("May ");} if(mon == 6){lcd.print("Jun ");} if(mon == 7){lcd.print("Jul ");} if(mon == 8){lcd.print("Aug ");} if(mon == 9){lcd.print("Sep ");} if(mon == 10){lcd.print("Oct ");} if(mon == 11){lcd.print("Nov ");} if(mon == 12){lcd.print("Dec ");} }