Documente Academic
Documente Profesional
Documente Cultură
php/Ar
duino_LCD_KeyPad_Shield_(SKU:_DFR0009)
Arduino LCD KeyPad Shield (SKU:
DFR0009)
Contents
[hide]
1 Introduction
2 Diagram
3 Pin Allocation
4 Sample Code
o 4.1 Example use of LiquidCrystal library
o 4.2 Example use of Enhanced LiquidCrystal_I2C library(Not updated)
5 Documents
Introduction
Diagram
Pin Allocation
Pin Function
Digital 4 DB4
Digital 5 DB5
Digital 6 DB6
Digital 7 DB7
Digital 9 Enable
Sample Code
Example use of LiquidCrystal library
//Sample using LiquidCrystal library
#include <LiquidCrystal.h>
/*******************************************************
This program will test the LCD panel and the buttons
Mark Bramwell, July 2010
********************************************************/
// For V1.0 comment the other threshold and use the one below:
/*
if (adc_key_in < 50) return btnRIGHT;
if (adc_key_in < 195) return btnUP;
if (adc_key_in < 380) return btnDOWN;
if (adc_key_in < 555) return btnLEFT;
if (adc_key_in < 790) return btnSELECT;
*/
void setup()
{
lcd.begin(16, 2); // start the library
lcd.setCursor(0,0);
lcd.print("Push the buttons"); // print a simple message
}
void loop()
{
lcd.setCursor(9,1); // move cursor to second line "1" and 9 space
s over
lcd.print(millis()/1000); // display seconds elapsed since power-up
}
Example use of Enhanced LiquidCrystal_I2C library(Not
updated)
This library inherits LiquidCrystal and adds another method: button - to read button pushed on a
keypad. This works on the Old version of the board V1.0
Library Forum
/*
DFRobot LCD Shield for Arduino
Key Grab v0.2
Written by Glendon Klassen
gjklassen@gmail.com
http://www.sourceforge.net/users/ecefixer
http://ecefixer.tumblr.com
None - 0
Select - 1
Left - 2
Up - 3
Down - 4
Right - 5
*/
#include <LiquidCrystal.h>
#include <DFR_Key.h>
DFR_Key keypad;
int localKey = 0;
String keyString = "";
void setup()
{
lcd.begin(16, 2);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Key Grab v0.2");
delay(2500);
/*
OPTIONAL
keypad.setRate(x);
Sets the sample rate at once every x milliseconds.
Default: 10ms
*/
keypad.setRate(10);
void loop()
{
/*
keypad.getKey();
Grabs the current key.
Returns a non-zero integer corresponding to the pressed key,
OR
Returns 0 for no keys pressed,
OR
Returns -1 (sample wait) when no key is available to be sampled.
*/
localKey = keypad.getKey();
if (localKey != SAMPLE_WAIT)
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Current Key:");
lcd.setCursor(0, 1);
lcd.print(localKey);
}
}
https://www.youtube.com/watch?v=QRlVQWmIGgM
https://www.youtube.com/watch?v=gRhYla6mzkM
http://www.hobbyist.co.nz/?q=diy-tutorials
LCD Pinout and getting it going with the
Arduino!
LCD 1602 pinout and Interface
The LCD pins are numbered from 1- 16 , look behind the LCD to see
the numbering.
The table below explains how to connect the LCD pins to the
Arduino.
In the case where the LCD is powered with the Arduino by the 5V
USB cable, selecting the contrast resistor to be 2K ohm and the
back LED resistor to be 100 ohm is a good start. Alternatively, a 5K
potentiometer can be used to adjust the contrast for vest viewing.
Wiring with Arduino
Follow the above table and circuit diagram in Fig 1, and wire up the
LCD using the wires provided.
Color coding:
Wire Color Description
BLACK Ground
Other colors Data and signal lines