LCD Keypad Shield Library for Proteus V1.0: an Arduino UNO V4.0 with the yellow-green LCD keypad shield showing Key: LEFT V2.0 and A0 = 625 3.05V, the Advance pop-up Keypad tool and the built-in serial monitor with the key values

LCD Keypad Shield Library for Proteus V1.0 (16x2 + 5 Buttons)

2.5K Views
40
700
60
25
60
PCBWay

Hello friends, I hope you all are doing great. Today, I am going to share the new LCD Keypad Shield Library for Proteus V1.0. The LCD keypad shield is one of the most popular first boards for the Arduino UNO: a 16x2 LCD, five buttons and a contrast trimmer on one board that simply plugs onto the UNO. No wiring, no breadboard, and your project has a display and a small keyboard. With this LCD Keypad Shield Library for Proteus, you get the same shield in your simulation: the LCD shows what your sketch prints, and you press the buttons with the mouse.

The shield runs on our own HD44780 model from the LCD 16x2 Library for Proteus V3.0, and the five buttons are modelled the way the real board does it: a resistor ladder that puts a different voltage on A0 for every button, so analogRead(A0) in your sketch reads what a real shield gives. We modelled the two real versions of the shield, and the famous D10 backlight flaw of the common one. You get four devices (blue and yellow-green LCD, each as Simple with a live STATUS panel and as Advance with a pop-up window and four test tools), and the demo runs on our new Arduino UNO V4.0 with its built-in serial monitor.

NOTICE: This library is very special to our team. A keypad shield looks simple, but the details are where projects fail: two shield versions with different button values, a backlight pin that can overload your Arduino, keys that bounce. We modelled all of that, tested it with the real Arduino libraries on a PC and in Proteus, and redrew the shield so every part is clear on the black board. It took our team a lot of hard work and many test runs. Your feedback is the fuel that keeps us going, so please tell us what you think in the comments below or in the LCD Library board of our forum. And if our free libraries help you, you can buy us a coffee. So, let's get started with the LCD Keypad Shield Library for Proteus V1.0:

LCD Keypad Shield Library for Proteus V1.0: an Arduino UNO V4.0 with the yellow-green LCD keypad shield showing Key: LEFT V2.0 and A0 = 625 3.05V, the Advance pop-up Keypad tool and the built-in serial monitor with the key values
Figure: The LCD Keypad Shield demo in Proteus 8.5: node 2 (yellow-green, Advance, the V2.0 shield) on our Arduino UNO V4.0 with LEFT held: "Key: LEFT V2.0", "A0 = 625 3.05V"; the pop-up's Keypad tool and the UNO's built-in monitor.

What is an LCD Keypad Shield?

An LCD keypad shield is an Arduino UNO shield with a 16x2 character LCD (the common 1602 with the HD44780 controller and a backlight), five buttons (SELECT, LEFT, UP, DOWN, RIGHT), a RST button for the Arduino and a blue contrast trimmer. The original is DFRobot's DFR0009; today most shields are its clones, usually on a black board. The shield plugs onto the UNO's headers, so every connection is made by the board itself.

The LCD uses Arduino's LiquidCrystal library in 4-bit mode on six pins, and the backlight hangs on D10. The buttons are the clever part: instead of five pins, they share one analog pin, A0. If you are new to the LCD itself, start with our Introduction to 16x2 LCD Module. For a 4x4 matrix keypad on digital pins, see our Arduino Keypad Interfacing.

The LCD Keypad Shield at a Glance

The LCD keypad shield in numbers
FeatureValue
LCD16x2 characters, HD44780 controller, blue or yellow-green backlight
LCD pinsRS on D8, E on D9, D4 - D7 on D4 - D7 (4-bit), RW tied to GND: LiquidCrystal lcd(8, 9, 4, 5, 6, 7)
ButtonsSELECT, LEFT, UP, DOWN, RIGHT on A0 (a resistor ladder), RST on the Arduino's RESET
BacklightD10, through a transistor
ContrastA 10k trimmer on the board
Free pinsA1 - A5, D0 - D3, D11 - D13 (the shield passes them through)
Supply5 V from the Arduino
BoardAbout 80 x 58 mm

How Five Buttons Share One Analog Pin

A0 is held at 5 V by a 2k pull-up resistor. Each button connects A0 to GND through a different part of a resistor ladder: RIGHT shorts A0 straight to GND, UP goes through the first resistor, DOWN through the first two, and so on. Every button makes a different voltage divider, so every button gives a different voltage on A0, and analogRead(A0) tells you which one is held. With no button, A0 reads 1023.

There are two versions of the shield with different ladders, and our library models both (the SHIELD property). These are the values the sketch read in Proteus, at 5.00 V:

The two A0 ladders (the resistance from A0 to GND with each button held)
ButtonV1.0 (most clones)analogReadV2.0 (DFRobot DFR0374)analogRead
RIGHT0 ohm (a short)00 ohm (a short)0
UP330 ohm, 0.71 V145510 ohm, 1.02 V208
DOWN950 ohm, 1.61 V3301330 ohm, 2.00 V409
LEFT1950 ohm, 2.47 V5063130 ohm, 3.05 V625
SELECT5250 ohm, 3.62 V7428230 ohm, 4.02 V824
(none)open, 5.00 V1023open, 5.00 V1023

Tables online often give 329, 505 and 741 for V1.0: one count less, because real ADCs and resistors differ by a count or two. That is why a sketch should never compare against exact values. It should use limits half way between the buttons. Our demo's limits, 70 / 268 / 457 / 683 / 923, read both versions.

The D10 Backlight Flaw

The backlight is switched by a transistor whose base hangs on D10. On the V1.0 shield (most clones), a 4.7k resistor pulls the base up, but there is no resistor between D10 and the base. If a sketch makes D10 an OUTPUT and writes it HIGH, the pin drives the transistor's base directly, and real shields have been measured at over 100 mA on D10, while the ATmega328P's limit is 40 mA per pin. The same happens with analogWrite(10, ...). The safe way works on every shield: write D10 LOW once, then pinMode(10, INPUT) turns the backlight on (the shield's pull-up) and pinMode(10, OUTPUT) turns it off. The V2.0 shield adds a 10k base resistor, so HIGH and PWM are safe there. Our model knows which version it is and warns you, as you will see below.

What's New in LCD Keypad Shield Library for Proteus V1.0

Here is what the first version brings:

  • The LCD keypad shield on our own HD44780 model in TEPLCD.DLL, the same model as our LCD 16x2 V3.0, wired as on the shield (D4 - D9).
  • Five buttons on A0 as a real analog voltage: hold a button with the mouse, the sketch's analogRead(A0) reads it.
  • Both shield versions: V1.0 (most clones) and V2.0 (DFR0374), with their own ladders and backlight circuits.
  • The D10 overload warning: a red banner, a TEP LED and a log line when a sketch drives D10 HIGH on a V1.0 shield.
  • A clickable contrast trimmer and a working RST button.
  • A real shield on the schematic: the black board with our green LCD 16x2 board on top, the six buttons in their real places and silver switch bodies that stand out on the black board.
  • Four devices in TEPLCDKEYPAD.LIB: blue and yellow-green LCD, each Simple and Advance.
  • Four test tools on the Advance: Init check, Keypad (with buttons that press a key for you), Backlight D10 and Timing.
  • A two-UNO demo on our Arduino UNO V4.0: one V1.0 and one V2.0 shield, a key tester, a menu, a counter and a stopwatch, and Serial commands.
  • A compact package: about 1.37 MB, without the C++ source code.

The model file TEPLCD.DLL is shared with our other LCD libraries and runs their devices too (we re-ran their five demos on it). If you have them, keep this newer DLL. The keypad shield has its own LIB file, so our LCD Library for Proteus V3.0 stays as it is.

LCD Keypad Shield Simple vs LCD Keypad Shield Advance

All four devices share one model and the same shield. They differ in the LCD colour and in where you see the extras:

The four devices (search "LCDKEYPAD" in Pick Devices; category Optoelectronics > Alphanumeric LCDs)
DeviceName in Pick DevicesLCDExtras
LCDKEYPADBLUETEPLCD Keypad Shield V1.0 Blue - SimpleBlueSTATUS panel on the sheet
LCDKEYPADBLUEADVTEPLCD Keypad Shield V1.0 Blue - AdvanceBluePop-up window and tools
LCDKEYPADGREENTEPLCD Keypad Shield V1.0 Yellow-green - SimpleYellow-greenSTATUS panel on the sheet
LCDKEYPADGREENADVTEPLCD Keypad Shield V1.0 Yellow-green - AdvanceYellow-greenPop-up window and tools

Pick a Simple shield when you want the key, the A0 value and the backlight state right on the schematic. Pick an Advance shield when the schematic is crowded, or when you want the bus log and the tools. Every device takes the SHIELD property: V1.0 or V2.0.

Download LCD Keypad Shield Library for Proteus

Click the button below to download LCD-Keypad-Shield-Library-for-Proteus-v1.0.zip (about 1.37 MB, without the C++ source code):

LCD Keypad Shield Library for Proteus V1.0
  • README.txt: a detailed guide to the files, the wiring, the two versions, the test tools and real hardware.
  • Proteus Library Files: TEPLCDKEYPAD.LIB (all four devices) and our Arduino library V4.0, ArduinoV4TEP.LIB, with the Arduino UNO V4.0 of the demo.
  • Proteus Model Files: TEPLCD.DLL and TEPARDUINO.DLL.
  • Proteus Simulation: LCD-Keypad-Shield-ArduinoUnoV4.pdsprj, LCD_Keypad_Demo.hex (both UNOs run it) and copies of both DLLs.
  • Arduino Code: LCD_Keypad_Demo.ino, the demo sketch. It needs only Arduino's LiquidCrystal library, which comes with the Arduino IDE.

The Arduino files are the ones of our Arduino Library for Proteus V4.0, so if you have it installed, they are the same. No Proteus yet? Read How to Download and Install Proteus 7 and 8. New to libraries? Follow How to Install a New Library in Proteus.

How to Install LCD Keypad Shield Library for Proteus

  1. Close Proteus and extract the whole zip file to a normal folder, for example your Desktop.
  2. Copy the two files from Proteus Library Files into the LIBRARY folder, usually C:\Program Files (x86)\Labcenter Electronics\Proteus 8 Professional\LIBRARY (on some PCs C:\ProgramData\Labcenter Electronics\Proteus 8 Professional\LIBRARY; use the folder that already holds Proteus's own .LIB files).
  3. Copy TEPLCD.DLL and TEPARDUINO.DLL from Proteus Model Files into the MODELS folder.
  4. Delete TEPLCDKEYPAD.IDX from the LIBRARY folder if there is one; Proteus makes a new index.
  5. Start Proteus, press P and search for LCDKEYPAD. You get the four devices.

Tip: the demo project needs the .hex file and the two DLLs beside it, so keep the Proteus Simulation folder together. The library was tested in Proteus 8.5; Proteus 7 is not supported.

The LCD Keypad Shield in Proteus

The part looks like the real shield: the black board, our green LCD 16x2 board on top, the blue trimmer in the top-left corner, the UNO's header rows at their real places and the six buttons in their two staggered rows. The Proteus pins sit where the real shield uses a pin: D4 - D10 on the top edge, RST, 5V, GND and A0 on the bottom edge. Here is LCD1, the blue Simple shield (a V1.0 shield), with UP held:

LCD Keypad Shield Simple in Proteus: the blue LCD showing Key: UP V1.0 and A0 = 145 0.70V, the UP button with its yellow ring, the KEY LED lit, and the STATUS panel with KEY UP and A0 0.71 V = 145
Figure: LCD1 (blue, Simple, V1.0) with UP held: the glass shows "Key: UP V1.0", "A0 = 145 0.70V"; the panel says KEY UP, A0 0.71 V = 145, D10 INPUT - ON (SAFE).

Pinout

The shield's Proteus pins (D4 - D10 on top, RST / 5V / GND / A0 at the bottom)
PinArduino UNO pinWhat it does on the shield
D4 - D7D4 - D7The LCD's data lines DB4 - DB7 (4-bit bus)
D8D8The LCD's RS
D9D9The LCD's E
D10D10The backlight transistor
A0A0The five buttons (the resistor ladder)
RSTRESETThe RST button pulls the Arduino's RESET low
5V, GND5V, GNDSupply

The Board Up Close

LCD Keypad Shield board in Proteus up close: the blue contrast trimmer, the header rows with the D4 to D10 pins, the green LCD 16x2 board with the PWR, CMD and DATA LEDs, the six silver buttons and the KEY and D10 LEDs
Figure: The board of LCD1: the trimmer (V0 0.75 V), the header rows, the LCD with its PWR / CMD / DATA LEDs, the six buttons, and the TEP KEY and D10 LEDs.

Everything you see is drawn live by the model while the simulation runs: the glass with its backlight, the trimmer's slot turning with the contrast, the pressed button and the LEDs. The real shield has no LEDs; the PWR, CMD and DATA LEDs on the LCD and the KEY and D10 LEDs on the shield are our additions to help you see what happens.

LEDs and Indicators

Board indicators
IndicatorWhat it showsOn the real shield?
The glassWhat the HD44780 shows, with the backlight and the contrastYes
PWR LED (red)Lit while the LCD has powerTEP addition
CMD / DATA LEDsFlash on every command / characterTEP addition
KEY LED (yellow)Lit while a button on A0 is heldTEP addition
D10 LED (red)Lit while D10 overloads a V1.0 shieldTEP addition
The yellow ringThe button that is heldTEP addition
V0 readoutThe contrast voltage beside the trimmerTEP addition

Component Properties

Shield properties (double-click the shield > Edit Properties)
PropertyMeaningDefault
PANELSimple devices only: the STATUS panel at the start, OPEN or CLOSEDOPEN
SHIELDV1.0 (most clones, the D10 flaw) or V2.0 (DFR0374)V1.0
TRIMMERThe contrast trimmer at the start, 0 - 100 %15
BACKLIGHTD10 (from the D10 pin), ON or OFF (forced)D10
CONTRASTTRIMMER or AUTO (always good)TRIMMER

Pressing the Buttons

Hold a button with the mouse: it stays pressed while the mouse button is down. The model puts that button's voltage on A0 within 10 ms, the switch gets a yellow ring, and the KEY LED lights. Let go, and A0 goes back to 5 V. Here is LEFT on the V1.0 shield:

LCD Keypad Shield LEFT button pressed in Proteus: the LCD shows Key: LEFT V1.0 and A0 = 506 2.47V, the LEFT button with its yellow ring and the KEY LED lit
Figure: LEFT held on the V1.0 shield: "Key: LEFT V1.0", "A0 = 506 2.47V" - the value the sketch read with analogRead(A0).

The sketch shows the shield version it guesses from the values (UP 145 is a V1.0 shield, UP 208 a V2.0). The RST button works too: it holds the Arduino in reset while you hold it, and the UNO starts again when you let go.

The D10 Trap Made Visible

Our demo has a command to make the mistake on purpose: LIGHT HIGH makes D10 an OUTPUT and writes it HIGH. On LCD1, a V1.0 shield, the model reacts at once:

LCD Keypad Shield D10 overload in Proteus: the red banner D10 OVERLOAD - OUTPUT HIGH ON A V1.0 SHIELD: OVER 100 mA, the D10 LED lit, the D10 readout OUTPUT HIGH - OVERLOAD and the log lines
Figure: LIGHT HIGH on the V1.0 shield: the banner D10 OVERLOAD - OUTPUT HIGH ON A V1.0 SHIELD: OVER 100 mA (USE INPUT), the D10 LED lit, D10 "OUTPUT HIGH - OVERLOAD".

The simulation log gets a warning line too. Type LIGHT ON and the sketch switches the backlight the safe way again. On the V2.0 shield the same command is safe, and the Backlight D10 tool says so.

The Contrast Trimmer

Click the trimmer's left half (-) to turn the contrast down or its right half (+) to turn it up, 5 % a click; the voltage V0 is shown beside it. Too far one way and dark blocks appear behind the text, too far the other way and the text fades. Here it is at V0 0.00 V:

LCD Keypad Shield contrast trimmer at V0 0.00 V in Proteus: dark blocks behind every character on the blue LCD
Figure: Three clicks on the trimmer's "+" half: V0 0.00 V, the contrast too high - dark blocks behind the characters. At 2.25 V the text fades; 15 % (0.75 V) is good.

This is exactly what you see on a real shield when the trimmer is wrong, and it is the first thing to check when a real LCD stays blank.

LCD Keypad Shield Simple: The STATUS Panel

Under the Simple shield sits the STATUS panel (see the pictures above):

The STATUS panel
PartWhat it shows
BannerREADY (the 4-bit bus on D4 - D9, 2 lines, display on), D10 OVERLOAD, NOT INITIALISED, TOO FAST or NO POWER
DISPLAY, CURSOR, ADDRESSThe LCD controller's state
KEY, A0The button held and the A0 voltage with its analogRead value
5V, CONTRASTThe supply and the contrast with V0
BACKLIGHT, D10The backlight and how D10 drives it: INPUT, OUTPUT LOW, OUTPUT HIGH or PWM
WRITESThe bytes the LCD took
LogThe last 6 events: bus transfers, key presses and D10 changes
ButtonsBACKLIGHT (D10, ON, OFF) and CONTRAST (TRIMMER, AUTO (GOOD))

The red X in the panel's header closes it, and PANEL on the board opens it again.

LCD Keypad Shield Advance: The Pop-Up Window

The Advance shield keeps only the shield on the schematic. In the demo, LCD2 is a yellow-green Advance shield, the V2.0 version. Hold SELECT for a second and the demo opens its menu:

LCD Keypad Shield Advance in Proteus: the yellow-green LCD showing the demo menu with Counter selected and Stopwatch, the board with ADVANCE and OPEN PANEL
Figure: LCD2 (yellow-green, Advance, V2.0): the demo's menu after SELECT held 1 s and one DOWN.

At Run, the "TEP LCD Keypad Shield Advance" pop-up opens with the look of our TEP Serial Monitor: move it by its header, resize or minimise it, and reopen it with OPEN PANEL. The header has the Display, Bus log and Tests tabs and the theme, Settings and Help icons.

The Display Page

LCD Keypad Shield Advance Display page in Proteus: a big copy of the yellow-green LCD, the bus, lines, font, display, cursor, blink, entry and address tiles, DDRAM, CGRAM, the supply, contrast, backlight and key card and the latest transfers
Figure: The Display page: the big glass ("Key: none V2.0"), the controller's state, DDRAM, and "Backlight 100 % (D10 INPUT) Key none = 1023".

The Display page shows a big copy of the glass, the controller's state, DDRAM and CGRAM, a card with 5V, the contrast, the backlight and the key, and the latest transfers. Its toolbar overrides the backlight (D10, On, Off) and the contrast (Trimmer, Auto).

The Bus Log Page

LCD Keypad Shield Advance bus log in Proteus: every byte on the D4-D7, RS D8, E D9 bus with time, gap, kind, byte, meaning and margin
Figure: The Bus log: every byte on the bus, newest first - here the demo redrawing its home screen.

Every byte the LCD took, with the time, the gap to the previous byte, CMD or DATA, the meaning and the margin to the controller's busy time. Filters, Pause and Clear help you catch one moment.

The Tests Page: Four Test Tools

The tools read the model's own state while the simulation runs. Each has a bold "Good for:" line and a verdict per row: green is fine, amber means check, red means wrong. All the results below come from LCD2 in Proteus 8.5.

1. Init Check: Is the Start-Up Right?

LCD Keypad Shield init check in Proteus: wait after power-on 66.3 ms, nine function sets, 4-bit, 2 lines, display on, clear, entry mode, no byte ignored, the verdict green, and the start-up transfers
Figure: Init check: every row green; LiquidCrystal initialises the LCD twice - its constructor and lcd.begin().

Good for: "an LCD that stays blank or shows a row of blocks - is the sketch's lcd.begin() right?" The tool compares the start-up with the HD44780 datasheet: 66.3 ms after power-on, the wake-up function sets, 4-bit, 2 lines, display on, clear and entry mode, with no byte lost.

2. Keypad: Which Value Does Each Button Give?

LCD Keypad Shield keypad tool in Proteus: the V2.0 ladder, A0 now 3.05 V = analogRead 625 with LEFT held, every button with its resistance, volts and analogRead on both versions, Press and Hold buttons, a 0 to 1023 scale and the code that reads the keys
Figure: Keypad: the V2.0 ladder, "3.05 V = analogRead 625 - LEFT held", every button on both versions, the demo's limits and the code that reads them.
Keypad (LCD2, a V2.0 shield)
RowResult in the picture
This shieldV2.0 ladder: 2k pull-up, 510 / 820 / 1.8k / 5.1k (DFRobot DFR0374)
A0 now3.05 V = analogRead 625 - LEFT held
Presses6 since Start - RIGHT 1, UP 1, DOWN 1, LEFT 2, SELECT 1, RST 0
The tableEvery button: its resistance to GND, volts, analogRead here and on a V1.0, the demo's range
The scale0 - 1023: big dots for this shield, small for the other version, lines for the limits

Good for: "a key that reads wrong - each button's A0 value on this shield, and limits that work." The Press buttons hold a key for 0.3 s and Hold keeps it down until you click again, so you can test a sketch without the mouse on the board.

3. Backlight D10: Is the Backlight Switched Safely?

LCD Keypad Shield backlight D10 tool in Proteus: the V2.0 shield with a 10k base resistor, D10 OUTPUT HIGH safe, backlight 100 percent, the verdict safe and the safe code
Figure: Backlight D10 after LIGHT HIGH on the V2.0 shield: "OUTPUT HIGH - backlight ON through the 10k base resistor (safe)".
Backlight D10 (LCD2, a V2.0 shield)
RowResult in the picture
This shieldV2.0: a 10k base resistor and a 5.1k pull-up on D10 - safe either way
D10 nowOUTPUT HIGH - backlight ON through the 10k base resistor (safe)
Backlight100 %
OUTPUT HIGH3.196 s in 1 period in the last 357.050 s
VerdictSafe for this shield

Good for: "a backlight that will not switch, or a V1.0 shield whose D10 is overloaded." On a V1.0 shield, OUTPUT HIGH and PWM are flagged as an overload. Under the rows, the tool shows the safe code that works on every version, and the D10 changes with their times.

4. Timing: Is the Sketch Too Fast for the LCD?

LCD Keypad Shield timing tool in Proteus: 18681 bytes measured, none ignored, the smallest margin 260.0 us, 782.6 us to spare after a clear, the shortest E pulse 6.2 us over 37356 pulses
Figure: Timing: no byte ignored in 18,681; the smallest margin 260.0 us; the shortest E pulse 6.2 us.

Good for: "lost characters or commands - every byte must wait for the previous one's busy time." The demo sent 18,681 bytes without one lost: LiquidCrystal waits long enough.

LCD Keypad Shield with Arduino in Proteus

Open LCD-Keypad-Shield-ArduinoUnoV4.pdsprj from the Proteus Simulation folder, with LCD_Keypad_Demo.hex and both DLLs beside it. The demo runs on two of our Arduino UNO V4.0 boards from the Arduino UNO Library for Proteus V4.0: working ON / L / TX / RX LEDs, a RESET button and a serial monitor built into the board. Both UNOs run the same HEX file:

  • NODE 1 - SIMPLE: ARD1 with LCD1 (blue, Simple, SHIELD V1.0 - a clone).
  • NODE 2 - ADVANCE: ARD2 with LCD2 (yellow-green, Advance, SHIELD V2.0 - DFR0374).
LCD Keypad Shield Arduino Proteus circuit running: two Arduino UNO V4.0 boards, the blue Simple shield with its STATUS panel and the yellow-green Advance shield, both showing the key tester
Figure: The whole circuit running, without the pop-up windows: both shields on their key tester screen.

Wiring

On a real UNO the shield simply plugs in. In Proteus the shield is a part next to the UNO, and every pin reaches the UNO through a net label: terminals with the same name are connected. D4_1 at the shield meets D4_1 at ARD1's D4 pin, and node 2 has its own labels, so the two circuits stay apart. 5V goes to the VCC label and GND to the ground symbol, Proteus's power rails.

LCD Keypad Shield wiring in Proteus with net labels: the Arduino UNO V4.0 D4 to D10, A0 and RESET pins labelled D4_1 to D10_1, A0_1 and RST_1, and the shield pins with the same labels, VCC and the ground symbol
Figure: Node 1: ARD1's D4 - D10, RESET and A0 with their labels, and the same labels on LCD1's pins.
Demo wiring (node 1; node 2 uses _2)
Shield pinArduino UNOLabel in the demo
D4 - D7D4 - D7D4_1 ... D7_1
D8, D9, D10D8, D9, D10D8_1, D9_1, D10_1
A0A0A0_1
RSTRESETRST_1
5V, GND5V, GNDVCC, the ground symbol

The serial monitor needs no wires: it is built into the UNO V4.0 on D0 / D1, like the USB chip of a real UNO (see our Introduction to Arduino UNO).

The Arduino Code

The demo sketch, LCD_Keypad_Demo V1.0, uses only Arduino's LiquidCrystal library. The LCD is created with the shield's pins:

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);   // RS, E, D4, D5, D6, D7
const byte BACKLIGHT_PIN = 10;

The keys are read with limits half way between the values, so the same sketch reads both shield versions:

const int LIMIT[5] = {70, 268, 457, 683, 923};
Key readKey() {
  adc = analogRead(A0);
  for (byte k = 0; k < 5; k++)
    if (adc < LIMIT[k]) return (Key)k;
  return KEY_NONE;
}

Real buttons bounce, so the loop scans the keys every 5 ms and a new reading must hold for 30 ms before it counts:

  if (now - lastScan < 5) return;
  lastScan = now;
  Key k = readKey();
  if (k != lastRead) { lastRead = k; readSince = now; }
  if (k != stableKey && now - readSince >= 30) {

Holding SELECT for one second opens the menu:

    if (screen == HOME && stableKey == KEY_SELECT && !longDone && now - pressedAt >= 1000) { longDone = true; go(MENU); }

And the backlight is switched the safe way, on every shield version:

void setLight(bool on) {
  lightOn = on;
  digitalWrite(BACKLIGHT_PIN, LOW);
  pinMode(BACKLIGHT_PIN, on ? INPUT : OUTPUT);
}

Only the LIGHT HIGH command does it the wrong way, to show the warning:

      pinMode(BACKLIGHT_PIN, OUTPUT);
      digitalWrite(BACKLIGHT_PIN, HIGH);

The sketch also guesses the shield version from the values the keys gave:

    if (abs(seen[k] - V1[k]) < abs(seen[k] - V2[k])) v1++; else v2++;

To change the sketch, export a new HEX file and load it into both UNOs; see How to get the HEX file from Arduino. New to Arduino? Start with our Arduino Tutorial for Beginners.

The Demo Screens and Commands

The demo sketch (commands are not case-sensitive)
Screen / commandWhat it does
Key tester (home)The key, the shield version guessed, the A0 value and its volts
Menu (SELECT held 1 s)UP / DOWN move, SELECT or RIGHT opens, LEFT goes back
BacklightSELECT switches the backlight the safe way
CounterUP / DOWN count (held = repeat), SELECT = 0
StopwatchSELECT starts / stops, DOWN = 0
HELP, STATUSThe command list; the screen, key, A0, backlight, counter and version
KEYSThe A0 value each key gave so far, and the version
TEXT <text>A message on line 2 of the home screen
LIGHT ON / OFF / HIGHThe backlight the safe way; HIGH = the V1.0 flaw on purpose
HOME, MENUGo to the key tester / the menu

How to Run the Demo

  1. Press Run. Both UNOs' monitor windows and LCD2's pop-up open; move them aside. The LCDs show "LCD Keypad V1.0", then the key tester.
  2. Hold the buttons of LCD1 with the mouse and watch the values (V1.0); press LCD2's keys from its Keypad tool (V2.0).
  3. Hold SELECT for a second for the menu; try the counter and the stopwatch.
  4. Type LIGHT HIGH in ARD1's monitor to see the D10 warning, then LIGHT ON.
  5. Click the trimmer halves, the panel's buttons and RST.

LCD Keypad Shield Proteus Simulation Results

Each Arduino UNO V4.0 carries its own copy of our TEP Serial Monitor Advance. Its window, "TEP Arduino UNO - ARD1", opens at Run, and a click on the board's USB port opens it again. The screenshots show its Simple interface (Ctrl+Shift+U, or the monitor's ... menu; Esc goes back to the full view). Read all about the monitor in TEP Serial Monitor Advance for Proteus.

ARD1: The V1.0 Shield

Built-in serial monitor of the Arduino UNO V4.0 in Proteus, Simple interface: every key of the V1.0 shield with its A0 value and the KEYS answer Shield: V1.0
Figure: ARD1's monitor: every key pressed with the mouse, and KEYS: 0, 145, 330, 506, 742 - "Shield: V1.0".
Key RIGHT (A0 = 0)
Key DOWN (A0 = 330)
Key LEFT (A0 = 506)
Key SELECT (A0 = 742)
Key UP (A0 = 145)
KEYS
RIGHT: 0
UP: 145
DOWN: 330
LEFT: 506
SELECT: 742
Shield: V1.0

ARD2: The V2.0 Shield

Built-in serial monitor of the Arduino UNO V4.0 in Proteus for the V2.0 shield: the KEYS answer 0, 208, 409, 625, 824 and Shield: V2.0
Figure: ARD2's monitor: the V2.0 values 0, 208, 409, 625, 824 - "Shield: V2.0".
Key SELECT (A0 = 824)
KEYS
RIGHT: 0
UP: 208
DOWN: 409
LEFT: 625
SELECT: 824
Shield: V2.0
Key LEFT (A0 = 625)

The Backlight Commands

Built-in serial monitor of the Arduino UNO V4.0 in Proteus: LIGHT HIGH with the warning over 100 mA on a real V1.0 shield, LIGHT OFF and LIGHT ON the safe way
Figure: ARD1: LIGHT HIGH (the warning), LIGHT OFF (D10 OUTPUT LOW) and LIGHT ON (D10 INPUT).
LIGHT HIGH
D10 = OUTPUT HIGH - over 100 mA on a real V1.0 shield!
Type LIGHT ON to switch it the safe way
LIGHT OFF
OK - backlight off (D10 = OUTPUT LOW)
LIGHT ON
OK - backlight on (D10 = INPUT)

Troubleshooting

  • A key reads as another key: the sketch's limits do not fit the shield. Look at the Keypad tool or the panel's A0 readout and use limits half way between the values.
  • No key works: A0 is not wired, or 5V / GND. With no key the panel's A0 readout says 5.00 V = 1023.
  • D10 OVERLOAD: the sketch drives D10 HIGH or uses analogWrite on a V1.0 shield. Switch the backlight with pinMode() instead.
  • The backlight never goes off: D10 must be an OUTPUT written LOW; INPUT means on.
  • A row of blocks: the LCD was not initialised. Check LiquidCrystal lcd(8, 9, 4, 5, 6, 7) and the D4 - D9 labels.
  • Faint characters or dark blocks: the contrast. Click the trimmer, or set CONTRAST AUTO.
  • The part or the UNO is not simulated, or no monitor window: TEPLCD.DLL or TEPARDUINO.DLL is missing from MODELS and the project folder; a closed monitor opens again with a click on the UNO's USB port.
  • The Advance pop-up does not appear: click OPEN PANEL on the shield, or turn "Open the panel at Run" back on in Settings.

Things to Know Before Using a Real LCD Keypad Shield

The demo sketch uses only LiquidCrystal and Serial, so it runs on a real UNO and shield too. Keep in mind:

  • Never drive D10 HIGH on a clone: most shields are V1.0. Use the pinMode() way, or add a 470 ohm resistor in series with the transistor's base.
  • Read your own values: run the demo's key tester, or a sketch that prints analogRead(A0), and use limits between the values.
  • Debounce: scan the keys every few milliseconds and wait for a steady reading.
  • The pins are taken: D4 - D10 and A0 belong to the shield; A1 - A5, D0 - D3 and D11 - D13 stay free.
  • Contrast first: a blank LCD is usually the trimmer.

Limitations of the Simulation

  • Not modelled: the overload's real current or damage (the model warns, the pin does not fail), switch bounce (the buttons are clean, but a sketch should still debounce), two keys at once, the 5x10 font on the glass and the shield's pass-through pins.
  • The board is drawn 61 mm tall instead of 58 mm so the parts get room; the LEDs, the yellow ring and the V0 readout are TEP additions.
  • The model is our own implementation, written from the HD44780 datasheet and the shields' published schematics. This library is not made or endorsed by DFRobot, Hitachi, Arduino or Labcenter.
  • Licences: the demo sketch uses Arduino's LiquidCrystal 1.0.7; the HEX file contains it and the Arduino AVR core 1.8.6, which include LGPL-licensed code; their source code is on GitHub.
  • Tested in Proteus 8.5 in October 2026 (the demo as shipped on two Arduino UNO V4.0 boards: every key with the mouse and from the pop-up, both versions, the menu, the D10 warning, the trimmer, the panel, RST, the pop-up and the four tools; about 0.63 x real time with the pop-up and both monitors open; our five earlier LCD demos re-run on the same DLL) and with automatic PC checks, 0 failed: 55 with the real demo sketch and Arduino's LiquidCrystal against the model, 7,202 on the HD44780 controller, 47 on the pop-up pages and the demo project read back from disk. Proteus 7 is not supported.

So, that was all about the LCD Keypad Shield Library for Proteus V1.0. I hope the buttons on A0, the two shield versions and the D10 warning make the keypad shield easy to understand, so your sketch works the first time you plug in a real one. If you use the LCD Keypad Shield Library for Proteus in a project, please share your feedback in the comments or in our forum, and if you have any questions, ask in the comments and I will help you out. Till the next tutorial, take care and have fun!


Comments

0

Join the conversation