Introduction: Arduino LCD!
Have you seen an lcd screen? Well, today, you can use a lcd keypad shield and program it to display things!
Parts:
DFRobot lcd keypad shield
arduino
computer
usb cable
Step 1: Hooking It Up(code)
//The code:
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
int readkey;
void setup() {
lcd.begin(16, 2);
lcd.print("Fathers day");
}
void loop() {
lcd.setCursor(0, 1);
lcd.print("It doesn't?");
readkey=analogRead(0);
if (readkey<50) {
lcd.clear();
lcd.print("Button Right");
}
else if(readkey<195) {
lcd.clear();
lcd.print("Button Up");
}
else if(readkey<380) {
lcd.clear();
lcd.print("Button Down");
}
else if(readkey<790) {
lcd.clear();
lcd.print("Button Left");
}
}
Step 2: Finished!
I am a 8-year old boy named Jason and I live in Canton,MI.
I did this by myself and you can see the video clip below.
Thanks for reading this instructable!
Update: I'm now 14 :)
Attachments

Participated in the
Pocket Sized Electronics
1 Person Made This Project!
- danitucek made it!
24 Comments
2 years ago
Hi, Rob Scott here (68 years old!). Thanks for the code. It helped me get started on the DF Robot LCD Keypad Shied used on an Arduino UNO. I had rusty pins on the unit, which when once cleaned, everything was OK.
4 years ago
Great code!
Works amazingly well and compatible with many shields.
Question 4 years ago
I cant get the keypad test to work
#include <LiquidCrystal.h>
lcd (8, 9, 4, 5, 6, 7);
int lcd;
int btnStr;
int currx;
int x;
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Analog 0: ");
lcd.print(currx);
lcd.setCursor(0, 1);
lcd.print(btnStr);
}
void loop() {
x = analogRead(A0); // the buttons are read from the analog0 pin
// Check if x has changed
if ((x != 1023) && (x != currx)) {
//update screen and change currx
lcd.setCursor(10, 0);
lcd.print(" ");
lcd.setCursor(10, 0);
lcd.print(x);
currx = x;
if (currx > 740 && currx < 745) {
btnStr = "Select";
} else if (currx > 500 && currx < 510) {
btnStr = "Left";
} else if (currx < 10) {
btnStr = "Right";
} else if (currx > 140 && currx < 150) {
btnStr = "Up";
} else if (currx > 320 && currx < 365) {
btnStr = "Down";
}
//update button pressed
lcd.setCursor(0, 1);
lcd.print(" ");
lcd.setCursor(0, 1);
lcd.print(btnStr);
}
delay(10);
}
I keep getting
Arduino: 1.8.6 (Windows 10), TD: 1.44, Board: "Arduino/Genuino Uno"
keypad_values.ino:2:5: error: expected constructor, destructor, or type conversion before '(' token
lcd (8, 9, 4, 5, 6, 7);
^
C:\Users\taran\Documents\Arduino\libraries\keypad_values\keypad_values.ino\keypad_values.ino.ino: In function 'void setup()':
keypad_values.ino:10:7: error: request for member 'begin' in 'lcd', which is of non-class type 'int'
lcd.begin(16, 2);
^
keypad_values.ino:12:7: error: request for member 'clear' in 'lcd', which is of non-class type 'int'
lcd.clear();
^
keypad_values.ino:13:7: error: request for member 'setCursor' in 'lcd', which is of non-class type 'int'
lcd.setCursor(0, 0);
^
keypad_values.ino:14:7: error: request for member 'print' in 'lcd', which is of non-class type 'int'
lcd.print("Analog 0: ");
^
keypad_values.ino:15:7: error: request for member 'print' in 'lcd', which is of non-class type 'int'
lcd.print(currx);
^
keypad_values.ino:16:7: error: request for member 'setCursor' in 'lcd', which is of non-class type 'int'
lcd.setCursor(0, 1);
^
keypad_values.ino:17:7: error: request for member 'print' in 'lcd', which is of non-class type 'int'
lcd.print(btnStr);
^
C:\Users\taran\Documents\Arduino\libraries\keypad_values\keypad_values.ino\keypad_values.ino.ino: In function 'void loop()':
keypad_values.ino:28:9: error: request for member 'setCursor' in 'lcd', which is of non-class type 'int'
lcd.setCursor(10, 0);
^
keypad_values.ino:29:9: error: request for member 'print' in 'lcd', which is of non-class type 'int'
lcd.print(" ");
^
keypad_values.ino:30:9: error: request for member 'setCursor' in 'lcd', which is of non-class type 'int'
lcd.setCursor(10, 0);
^
keypad_values.ino:31:9: error: request for member 'print' in 'lcd', which is of non-class type 'int'
lcd.print(x);
^
C:\Users\taran\Documents\Arduino\libraries\keypad_values\keypad_values.ino\keypad_values.ino.ino:36:14: warning: invalid conversion from 'const char*' to 'int' [-fpermissive]
btnStr = "Select";
^
C:\Users\taran\Documents\Arduino\libraries\keypad_values\keypad_values.ino\keypad_values.ino.ino:40:14: warning: invalid conversion from 'const char*' to 'int' [-fpermissive]
btnStr = "Left";
^
C:\Users\taran\Documents\Arduino\libraries\keypad_values\keypad_values.ino\keypad_values.ino.ino:44:14: warning: invalid conversion from 'const char*' to 'int' [-fpermissive]
btnStr = "Right";
^
C:\Users\taran\Documents\Arduino\libraries\keypad_values\keypad_values.ino\keypad_values.ino.ino:48:14: warning: invalid conversion from 'const char*' to 'int' [-fpermissive]
btnStr = "Up";
^
C:\Users\taran\Documents\Arduino\libraries\keypad_values\keypad_values.ino\keypad_values.ino.ino:52:14: warning: invalid conversion from 'const char*' to 'int' [-fpermissive]
btnStr = "Down";
^
keypad_values.ino:57:9: error: request for member 'setCursor' in 'lcd', which is of non-class type 'int'
lcd.setCursor(0, 1);
^
keypad_values.ino:58:9: error: request for member 'print' in 'lcd', which is of non-class type 'int'
lcd.print(" ");
^
keypad_values.ino:59:9: error: request for member 'setCursor' in 'lcd', which is of non-class type 'int'
lcd.setCursor(0, 1);
^
keypad_values.ino:60:9: error: request for member 'print' in 'lcd', which is of non-class type 'int'
lcd.print(btnStr);
^
exit status 1
expected constructor, destructor, or type conversion before '(' token
"Show verbose output during compilation"
option enabled in File -> Preferences.
5 years ago
This 74 yr old just took this exampleand developed an Azimuth/Elevation Controller for my Ham Radio Antenna.
5 years ago
Nice job young man. Keep at it. Just a tip for others, adjust the contrast. Some of these come with their contrast turned way down. It doesn't?
6 years ago
Eight, huh?
Well, you just got a 57 year old up and running.
I was looking for a quick heads up on the use of the module, and, that's what you did.
Ta, muchly.
6 years ago
Please consider this version to add button Select :
"
//The code:
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
int readkey;
void setup() {
lcd.begin(16, 2);
lcd.print("Fathers day");
}
void loop() {
lcd.setCursor(0, 1);
lcd.print("It doesn't?");
readkey=analogRead(0);
if (readkey<50) {
lcd.clear();
lcd.print("Button Right");
}
else if(readkey<195) {
lcd.clear();
lcd.print("Button Up");
}
else if(readkey<380) {
lcd.clear();
lcd.print("Button Down");
}
else if(readkey<555) {
lcd.clear();
lcd.print("Button Left");
}
else if(readkey<790) {
lcd.clear();
lcd.print("Button Select");
}
}"
6 years ago
Just got mine as well today. Only running into one minor oddity... I have the Exact same, and it seems to be drawing too much on the Uno's power, to the point the ATMega8U2 (It's a Uno R2, not R3) is not recognized by the computer (If I remove the shield, and plug the USb cable into the UNO, it prrecognizes it fine, and receives the program, and THEN I can plug the shield back on. But, if I try to program the UNO with the shield plugged on, the computer will compile, but refuses to load to the UNO.)
7 years ago
can you change button function with this?
7 years ago
Great start buddy, I'm 47 and just starting so your way ahead of me!!
Keep up the examples so us oldies can learn from you.
7 years ago on Introduction
Congratulations !
What I like the most is that you did it by yourself. Way to go kid.
Reply 7 years ago
Good work and well done you.
I found this very useful when starting out with a new lcd_keypad.
My own youngling is 12 and I am trying to get him interested in Arduino too.
Reply 7 years ago
Thanks for the reply! I hope your son is also interested in Arduino !
7 years ago
Great work kid
Reply 7 years ago
Thanks!
8 years ago on Introduction
Thank you for sharing this. I just opened my recently bought arduino lcd keypad shield and I needed a simple and fast tutorial on how to use it. Your instructables did that very well. It seems it cannot detect the sixth push button labeled "select"
Reply 7 years ago on Introduction
Hey. I can help you with a tutorial at this website: ladyada.com
Make sure you switch your dfrobot pins or you might break your arduino.
Peace Out!
Reply 8 years ago on Introduction
your welcome.
9 years ago on Introduction
Nice work.
Reply 7 years ago on Introduction
Thanks for replying to my instructable. Sorry for the very late comment :(