Bukit Mertajam, Penang

PROJECT 1 – “Hello World” ON LCD


“Hello World” ON LCD

Back to Project 0                                                                                                       Go to Project 2

Arduino LCD Keypad Shield or navigation shield which come with 6 momentary push button for menu navigation and also a 2×16 LCD. It only required to plug and use with Arduino main board and there no soldering or fly-wiring are required.







For the LCD Keypad Shield, it use total of 6-pins to control the LCD display which is pin-4,5,6,7,8,9. For LCD data, it use pin-4,5,6,7, while for the RS and Enable pin, it use pin-8 and 9. The Arduino-LCD Keypad Shield are only required to plug into the Arduino main board and there was no soldering are required such as shown in figure below.

Arduino LCD 2×16 Schematic

Arduino Keypad Schematic



The Arduino-LCD Keypad Shield are operate in 4-bits mode. To ease user, Arduino Team have prepared the <LiquidCrystal.h> file which we only require to modified and change the pin using only. For more information please check the Arduino LCD keypad Shield schematic.

For more example of the Arduino LCD Keypad coding, please refer to this webpage.




#include <LiquidCrystal.h>
Include the LiquidCrystal header file which is already prepared inside the Arduino libraries.

LiquidCrystal.lcd(8, 9, 4, 5, 6, 7);
In here, we set the pin using for LCD 4-bit mode by refer to Arduino Liquid Crystal webpage which is LiquidCrystal(rs, enable, d4, d5, d6, d7).

Int analogPin = A0;
Define the A0 as analogPin while assign a space to it as an integer.

Int adc_key_val[5] = {30 , 150 , 360, 535, 760};
Define the adc_key_val from 0 to 4 which contain the number inside the bracket. E.g: adc_key_val[1] = 150;

char msgs [5][15] = {“Right Key OK”,
                            “Up Key OK      ”,
                            “Down Key OK ”,
                            “Left Key OK    ”,
                            “Select Key OK”};
Define the each ASCII value in char which content of total 5 string and there was 15 ASCII value for each string.

Specified the dimension (width and height)of the LCD display.

Clear the screen of the LCD display.

lcd.print(“ CYTRON TECH.”);
Send the ASCII code to the LCD display according to the text enter.

Position the LCD cursor,that is set the location at which subsequent text written to the LCD will be displayed.

adc_key_in = analogRead(analogPin);
Read the value from the specified pin (analogPin) and store the value in the adc_key_in.

adc_key_in = get_key(adc_key_in);
Send the adc_key_in value to the get_key subroutine.

Print the text on the msgs[] to the LCD display according to the adc_key_in.

for(k = 0; k < NUM_KEYS; k++)
Loop from k=0 to k=4.

If(input < adc_key_val[k])
Check of the value from the analogPin are less than adc_key_val[k].

return k;
Replace the original k value with the number of k from 0 to 4.

If (k >= NUM_KEYS)
k = -1;
If detected the k value are large, assign k = -1.

Back to Project 0                                                                                                        Go to Project 2



1. P1 User Manual.pdf
2. Project_1_code.zip


Related Posts

Leave a comment