This week we continue the LCD discussion and show you how we got a serial (I2C) interface to an LCD to work.  We also show you a graphical display and the start of a new library we are creating for it.

We also, ordered and received since our last show the LCD shield from sainsmart.  We show you the simple change you need to make to the sample sketches to get them to work with this shield.  Also, how they implemented to buttons to save the number of pins used.

Downloads

HD Apple HD Apple SD Audio MP3 Android

Working I2C library for LCD Displays

download

How to install a Library

Serial LCD Sample Code

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x3F,20,4);  // set the LCD address to 0x27 for a 16 chars and 2 line display

void setup()
{
  lcd.init();                      // initialize the lcd
  lcd.init();
  // Print a message to the LCD.
  lcd.backlight();
  lcd.setCursor(3,0);
  lcd.print("Hello, world!");
  lcd.setCursor(2,1);
  lcd.print("Let's Make It");
   lcd.setCursor(2,2);
  lcd.print("Serial LCD Fun");
   lcd.setCursor(1,3);
  lcd.print("www.letsmakeit.tv");
}

void loop()
{
  lcd.setCursor(17, 0);
 
  lcd.print(millis()/1000);
}

Hello World sample LCD modified to work with LCD Shield

/*
  LiquidCrystal Library - Hello World
 
 Demonstrates the use a 16x2 LCD display.  The LiquidCrystal
 library works with all LCD displays that are compatible with the
 Hitachi HD44780 driver. There are many of them out there, and you
 can usually tell them by the 16-pin interface.
 
 This sketch prints "Hello World!" to the LCD
 and shows the time.
 
 This example code is in the public domain.

 http://www.arduino.cc/en/Tutorial/LiquidCrystal
 */

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis()/1000);
}