I2C/TWI LCD1602 Module

From ELECFREAKS-WIKI
Jump to: navigation, search

Introduction

LCDs are a fun and easy way to have your microcontroller project talk back to you. Character LCDs are common, and easy to get, available in tons of colors and sizes.But it find that the number of pins necessary to control the LCD can be restrictive, especially with ambitious projects.

The common charctic LCD need more than 6 pins for controlling. With the limited pin resources, your project may be out of resources using normal LCD shield. Here we provide the IIC LCD module, you only need 2 lines (I2C) to display the information.

By using simple i2c and SPI input/output expanders we have reduced the number of pins (only 2 pins are needed for i2c) while still making it easy to interface with the LCD.

LCD IICSPI 06.jpg

Feature

  • Work with any 'standard'16x2 character LCD
  • LCD Display Mode: STN, Positive, Transflective
  • Display Color: Deep Blue/ Yellow Green
  • Viewing Angle: 6H
  • Outline Dimension: 80*36*15.8 MAX

Schematic

LCD IICSPI 05.jpg

Pin definition and Rating

IIC Pin definition

Pin # Pad Type Description
GND 1 VSS Ground port
VCC 2 3.3V Integrated 3.3V(+)supply with on-chip linear regulator output within 3.15-3.3V
SDA 3 Data Data
SCL 4 Clock Clock

SPI Pin definition

Pin # Pad Type Description
GND 1 VSS Ground port
VCC 2 3.3V Integrated 3.3V(+)supply with on-chip linear regulator output within 3.15-3.3V
C 3 Clock Clock
D 4 Data Data
L 5 Latch Latch



Programming

IIC mode connect the CLK pin to Analog 5 (i2c SCL pin) and DAT to Analog 4 (i2c SDA pin). Connect the 5V and ground pins to respective power pins.

SPI mode connect the CLK pin to Digital 2 (SPI Clock pin) and D to Digital 3 (SPI DATA pin) and L to Digital 4 (SPI Latch pin). Connect the 5V and ground pins to respective power pins.

Here we used Freaduino v1.0 with ATMega328 (100% Arduino compatible) with UART/IIC and SPI interface breakout. So it easy connection.

The Library is base on Adafruit's IICLibrary, we had accorded our hardware do the appropriate changes. And you can easy choose SPI mode or IIC mode by the Switch


Includes important code snippet. Demo code like :

IIC Mode

<syntaxhighlight lang="php">

/*

Demonstration sketch for Adafruit i2c/SPI LCD backpack
using MCP23008 I2C expander
( http://www.ladyada.net/products/i2cspilcdbackpack/index.html )
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:

  1. include <Wire.h>
  2. 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);

}

</syntaxhighlight>


SPI Mode

<syntaxhighlight lang="php">


/*

Demonstration sketch for Adafruit i2c/SPI LCD backpack
using 74HC595 SPI expander
( http://www.ladyada.net/products/i2cspilcdbackpack/index.html )
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 Digital 2
* DAT to Digital 3
* LAT to Digital 4
  • /


// include the library code:

  1. include <Wire.h>
  2. include <LiquidCrystal.h>

// Connect via SPI. Data pin is #3, Clock is #2 and Latch is #4 LiquidCrystal lcd(3, 2, 4);

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);

}


</syntaxhighlight>

FAQ

Please list your question here:

Support

If you have questions or other better design ideas,

Version Tracker

Revision Descriptions Release
v1.0 Initial public release date

Resources

How to buy

Click here to buy:

See Also

Other related products and resources.

Licensing

This documentation is licensed under the Creative Commons Attribution-ShareAlike License 3.0 Source code and libraries are

licensed under GPL/LGPL, see source code files for details.

External Links

Links to external webpages which provide more application ideas, documents/datasheet or software libraries