Image 1

 

This is a 16×2 LCD and Keypad shield for Arduino Uno & and Freeduino boards.

It has a Blue Backlight with white words  & uses 4 Bit Arduino LCD Library .

The keypad has Select,Left, Up, Down and Right buttons apart from a RST button.

Screen contrast adjustment is done by a 10k trimpot seen at top left corner.

If you use the  Arduino example sketches,  use the following sequence of pins when starting the library

LiquidCrystal lcd(8,9,4,5,6,7);

The buttons are connected to only one analog input pin through resistors to give a different voltage for each button, thus saving on input/output pins.

 

Pin Connections

  PIN                  FUNCTION

Analog 0        Buttons (select, up, right, down and left)

Digital 4        DB4

Digital 5        DB5

Digital 6        DB6

Digital 7        DB7

Digital 8        RS (Data or Signal Display Selection)

Digital 9       Enable

Note: Do not use pin Digital 10 when this board is plugged in.

 

 

Image 3

 

Top side pin connections :

For connecting external devices like GPS,GSM some pins of Arduino are brought out as seen below

Pin 0(Rx) , Pin 1(Tx), Pins 2,3,11,12 & 13 are extended so that a berg stick is soldered here to make connections to external devices. Other pins are used for LCD connections and not available for peripherals.

Image6

 

Bottom side pin connections :

Image 7

 

Testing the LCD :

Under File –> Examples –> LiquidCrystal  of Arduino IDE  you see many sample programs for testing.

 

Image8

 

Select Hello World sketch & change the pin connection initialization as  :

LiquidCrystal lcd(8,9,4,5,6,7);

Image 9

Now upload the sketch to see the result “Hello World “ with counting on the LCD.

In the same manner you can try other sample programs by changing one line of program as above.

Here is another Sketch which displays the text typed into Serial monitor on to LCD.

———————————————————-

#include <LiquidCrystal.h>

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

int serial_in;

void setup()
{
lcd.begin(16,2);                            // set the lcd dimension
lcd.print(” www.alselectro.com“); // display the text
lcd.setCursor(0,1);                       // set lcd.setCursor (column,row)
lcd.print(” UART TESTING LCD”);
delay(3000);
lcd.clear();
lcd.setCursor(0,0);
Serial.begin(9600);                      // 9600 baud rate
}

void loop()
{
for (int lcd_cursor=0; lcd_cursor<32; lcd_cursor++)
{
if (lcd_cursor == 15) lcd.setCursor(0,1);
else if (lcd_cursor == 31) lcd.home();
while (!Serial.available()); // wait until there is signal  from computer
serial_in = Serial.read(); // Receive signal in ASCII
lcd.write(serial_in);
}
}

————————————————————-

 

 

KEYPAD SCHEMATIC

Image 2

 

To understand the function of keys ,refer to above schematic.

All keys are connected through series of resistors to Analog pin 0 (AD0).

When RIGHT key is pressed GND is directly applied to AD0.So AD0 = 0V.

When UP key is pressed the Resistor R3 (330E) is included.

Now the voltage at AD0 is calculated by OHM’s law  Vout =R2/(R1+R2)  * Vin

Image 4               Image 5

 

AD0  =    330/(2000+330) * 5  = 0.71 volt

 

When Down key is pressed  330E + 620E  resistors are included

AD0 = (330+620) / (2000+330+620) * 5  =  1.61 Volt

 

When Left key is pressed 330E,620E & 1000E resistors are included (total 1950E)

AD0= 1950/(2000+1950) * 5 =  2.47 volt

 

When Select key is pressed 330E,620E ,1000E  & 3300E  resistors are included  (total 5250E)

AD0 =  5250/(2000+5250)* 5 =  3.62 VOLT

If you use a multi meter to measure the voltage at AD0 pin you can see that when respective key is pressed the voltage shown in meter is close to the calculated values.

This voltage is the analog voltage that you’re reading as an input.

———————————————————

// sketch to test the key pressed & display on LCD as well as Serial monitor

#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
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.setCursor(0,0);
lcd.print(“LCD Key Shield”);
lcd.setCursor(0,1);
lcd.print(“Press Key:”);
Serial.begin(9600);
}

void loop() {
int x;
x = analogRead (0);
lcd.setCursor(10,1);
if (x < 100) {
lcd.print (“Right “);
Serial.print(“The value at pim A0 ‘Right key pressed’ is  :”);
Serial.println(x,DEC);
}
else if (x < 200) {
lcd.print (“Up    “);
Serial.print(“The value at pim A0 ‘UP key pressed’ is  :”);
Serial.println(x,DEC);
}
else if (x < 400){
lcd.print (“Down  “);
Serial.print(“The value at pim A0 ‘Down key pressed’ is  :”);
Serial.println(x,DEC);
}
else if (x < 600){
lcd.print (“Left  “);
Serial.print(“The value at pim A0 ‘Left key pressed’ is  :”);
Serial.println(x,DEC);
}
else if (x < 800){
lcd.print (“Select”);
Serial.print(“The value at pim A0 ‘Select key pressed’ is  :”);
Serial.println(x,DEC);
}
}

—————————————————————-

The Arduino has a circuit inside called an analog-to-digital converter that reads this changing voltage and converts it to a number between 0 and 1023.

When the RIGHT key is pressed, there are 0 volts going to the pin, and the input value is 0.

When the SELECT key is pressed, there are 3.6volts going to the pin and the input value is around 750 (for 5volt it is 1023). In between, analogRead() returns a number between 0 and 1023 that is proportional to the amount of voltage being applied to the pin.

Next, in the main loop of your code, you need to establish a variable to store the resistance value (which will be between 0 and 1023, perfect for an int data type) coming in from your keys

int x = analogRead(A0);

According to the value read , the LCD displays the corresponding key pressed & the Serial monitor of Arduino shows the value Read as well as key pressed.

 

Watch this support video :

 

ARDUINO LCD SHIELD WITH KEYPAD

 

WWW.ALSELECTRO.COM

cooltext753793315