SainSmart 1602 LCD Keypad Shield Example Fix
The issue, my new sainsmart LCD keypad 1602 would not work with the default arduino liquid crystal examples for hello world or any thing else in the example section of LCD. After some research I figured out the issue, the sainsmart has a unique pin layout and there is an easy fix. The default example uses a LCD array of //LiquidCrystal lcd(12, 11, 5, 4, 3, 2); but the sainsmart 1602 has a different layout. The Sainsmart pin array uses LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
Comment out or remove the the LINE of code with (12, 11, 5, 4, 3, 2)
//LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //<--removed
LiquidCrystal lcd(8, 9, 4, 5, 6, 7); //Code for SainSmart 1602 KeyPad
Below is a working code example using the
SainSmart LCD 1602 Keyboard Shield on an Arduino UNO
TIP: dial down the potentiometer screw to get a more clear display, for the brave remove the clear protective plastic film that covers the LCD.
//SainSmart 1602 keypad shield hello world example code
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
//LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
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!");
lcd.setCursor(0,1); // move to the begining of the second line
lcd.print("Second Line!");
}
void loop() {
// Turn off the display:
//lcd.noDisplay();
delay(500);
//Turn on the display:
lcd.display();
delay(1500);
}
PS: My wife asked if I was programming an old school pager ….I would have to agree with her on the sainsmart 1602 keypad does look like an old school retro beeper / pager.
None the less… for 10.99 at microcenter it has some serious potential, and loads of fun! perfect for teaching / learning to code on an LCD.
When I had the LCD display “I LOVE YOU” ….. made her smile