Arduino and LCD1602

A LCD display can be very useful in microcontroler projects, they make very easy to interface with user and configure your device properly and with great flexibility. So a display is important sometimes. I choose an lcd1602, it is small esay to use and has 2 lines and 16 characters.

20131219_224930_resized

20131219_225237_resized2

The connections are pretty simple, you connect vcc and ground to Arduino, and sda to Analog In 5 , and SCl to Arduino Analog in 4, as the diagram bellow shows.

Lcd1602-conn

There are several libraries available to lcd displays, so you have to be careful when you choose one. I used my original arduino library and got some strange characters in the begining and took me a while to realize that it was a software problem. Finally I found the right library LiquidCrystal Master.

This library has extra functions, to handle the spi and I2c interfaces for the model I used. The original library I found at Arduino site ( maybe it is updated now… ) would only handle a display without i2c interface, so you use almost all Arduino chips to connect in this configuration….

If you dont match the right library with the proper interface, you will end up like me, with several junk characters showing on… This library come with several exmples, I will show the hello world example.

This is the model I bought:
Display LCD1602

If you have another I2c device, you can connect to the display bus/ In this case you will need some pull up resistors to limit the current

i2ca

The code basically declares the LCD object, initialize it ( begin ) , and print the message ( print ) , the libray has other functions, and you can play with it. Have fun!!

/*
Demonstration sketch for Lcd i2c/SPI backpack

This sketch prints “Hello World!” to the LCD
and shows the time.

The circuit:
* 5V to Arduino 5V pin
* GND to Arduino GND pin
* CLK to Analog #5
* DAT to Analog #4
*/

// include the library code:
#include “Wire.h”
#include “LiquidCrystal.h”

// Connect via i2c, default address #0 (A0-A2 not jumpered)
LiquidCrystal lcd(0);

void setup() {
// set up the LCD’s number of rows and columns:
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);

lcd.setBacklight(HIGH);
delay(500);
lcd.setBacklight(LOW);
delay(500);
}