Arduino

Arduino + Sainsmart LCD2004 Serial 16×4 LCD Screen


Arduino Sainsmart LCD2004 Serial LCD

The Sainsmart LCD2004 is a great big 16 character by 4 line LCD screen that gives you a lot of output space but only using 2 output pins from the arduino instead of 6 output pins.

The unit can be connected via the analog  pin 4 to its SDA (data) and analog pin 5 to its SCL (clock). Each serial device gets a hardware address ranging from 0-127 (7-bit) and the recent batch of these are at I2C 0x3F address but you can change that.

Code

You will need to download the LiquidCrystal_I2C library from here.

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

#define I2C_ADDR 0x3F // Define I2C Address where the PCF8574A is
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7

LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin,BACKLIGHT_PIN,POSITIVE);

int n = 1;

void setup() {
  lcd.begin(20,4); // 20 columns by 4 rows on display
  lcd.setCursor(0,0); // go to the top left corner
  lcd.print("Test Message");&nbsp;
}

void loop() {
  lcd.setCursor (16,3); // go to col 16 of the last row
  lcd.print(n++,DEC);&nbsp;
  delay(500); // wait half a second before another update
}
openanalytics 4871 views

I'm a 35 year old UIUC Computer Engineer building mobile apps, websites and hardware integrations with an interest in 3D printing, biotechnology and Arduinos.


View Comments
There are currently no comments.

This site uses Akismet to reduce spam. Learn how your comment data is processed.