EAZYLife STEM LAB · MODULE 26

Digital Displays and Human Interfaces

Turn electronic states into information people can read, and turn human actions into reliable digital inputs. Explore displays, keypad scanning and interface design.

Free open lessonDigital input and outputArduino keypad + LCD build
INPUT · PROCESS · FEEDBACK
01 · HUMAN-MACHINE INTERFACES

Electronics must communicate with people

A human-machine interface (HMI) lets a person observe a system, provide commands and understand its response. A simple interface may use two LEDs and a pushbutton. A more capable one may combine a keypad, display, rotary encoder, touch panel, buzzer and status indicators.

Inputs from people

  • Pushbuttons and toggle switches
  • Numeric and matrix keypads
  • Rotary encoders and knobs
  • Touchscreens and touch sensors
  • Microphones and other interactive sensors

Feedback to people

  • LEDs and seven-segment numeric displays
  • Character LCDs and graphical OLEDs
  • Buzzer tones and sound prompts
  • Vibration and other tactile feedback
  • Clear status, error and confirmation messages
Human action
Input interface
Controller / logic
Display / feedback

Good interface design: the user should know what the system is doing, what input is expected, whether an action succeeded and how to recover from an error.

02 · SEVEN-SEGMENT DISPLAYS

Display numbers with seven controlled segments

A seven-segment display contains seven LED bars, labelled a to g, arranged to form decimal digits. Many parts also include a decimal-point LED. Each segment is an LED and needs current limiting unless the display module already includes suitable resistors and drivers.

Segment names and digit 8

abcdefgdp

To display 8, all seven segments are ON. Different combinations form the other digits.

Common cathode and common anode

COMMON CATHODECOMMON ANODECommon to GNDCommon to +VSegment HIGH = ONSegment LOW = ON

Common cathode: shared cathodes connect to ground; a segment lights when its anode is driven HIGH through a resistor.

Common anode: shared anodes connect to the positive supply; a segment lights when its cathode is pulled LOW through a suitable driver/resistor path.

Always identify the exact display pinout and common connection from its datasheet. Physical pin order is not universal.

Digit patterns (common-cathode logic convention)

DigitSegments ONHex pattern (gfedcba)
0a b c d e f0x3F
1b c0x06
2a b d e g0x5B
3a b c d g0x4F
4b c f g0x66
5a c d f g0x6D
6a c d e f g0x7D
7a b c0x07
8a b c d e f g0x7F
9a b c d f g0x6F

Bit order here is g-f-e-d-c-b-a, with bit 0 representing segment a. Drivers and libraries may use a different bit order or inverted logic.

03 · MULTIPLEXING AND DISPLAY DRIVERS

Control several digits without using a pin for every segment

A multi-digit display can share the a–g and decimal-point lines across digits. The controller enables one digit at a time, presents that digit's segment pattern, then rapidly moves to the next digit. Persistence of vision makes the sequence appear continuous when refresh is fast enough.

Four-digit multiplexing

DIGIT 1DIGIT 2DIGIT 3DIGIT 4Controller / driverShared segment bus + individual digit enables

At each scan step, turn the previous digit OFF, update the segment bus, then enable the next digit. This avoids ghosting caused by changing segment data while a digit is still active.

Why use a driver IC?

  • 74HC4511: BCD-to-seven-segment decoder/driver for compatible common-cathode displays. Check its output-current limits and whether external transistor drivers are required.
  • 74HC595: serial-in, parallel-out shift register. It reduces controller pin usage but still needs current limiting and suitable digit drivers.
  • TM1637/MAX7219 modules: integrated display-control solutions with their own wiring and library requirements.
  • Multiplexing reduces wiring, but each digit has a lower duty cycle. Design for peak and average LED current within ratings.

Do not connect a bare display directly to GPIO pins without appropriate current limiting. A microcontroller pin is not a power driver. Use transistor stages or a driver IC when display current exceeds the controller's permitted limits.

04 · INTERACTIVE SEVEN-SEGMENT DISPLAY

Choose a digit and inspect its segments

This teaching model shows the segment pattern for each decimal digit. Select a digit and switch between common-cathode and common-anode conventions. It is a logical display model, not an electrical simulation of a particular display module.

0x3Fa, b, c, d, e, fHIGH turns a segment ON in this common-cathode convention.
05 · MATRIX KEYPADS

Read many buttons with a row-and-column matrix

A 4×4 matrix keypad contains 16 switches arranged at row/column intersections. Instead of wiring every switch to its own input, the controller drives or scans rows and reads columns (or vice versa). A pressed key electrically connects one row to one column.

4×4 matrix scanning

C1C2C3C4R1R2R3R4

Scanning one row at a time lets the controller identify the column connected by a pressed switch. A keypad library handles much of this scan process.

Input reliability

  • Pull-up / pull-down: gives an unpressed input a defined logic level instead of allowing it to float.
  • Debouncing: prevents one physical press from appearing as several rapid presses.
  • Ghosting: some multi-key combinations can create ambiguous paths in simple matrix keypads; diode-equipped key matrices can address this.
  • Key events: distinguish pressed, held, released and repeated actions.
  • Validation: reject unexpected characters and handle full buffers safely.

Common keypad layout

123A456B789C*0#D

Keypad layouts and ribbon-cable pin order vary. Identify row and column connections with the module documentation or a continuity test before wiring.

06 · LCD AND OLED DISPLAYS

Show words, values and system status

16×2 character LCD

SYSTEM READYENTER CODE: _ _16 columns × 2 rows = 32 character positions

A common 16×2 LCD can show 32 character positions. An I²C backpack reduces wiring to power, ground, SDA and SCL, but its address and pin mapping must be confirmed.

OLED and graphical displays

TEMP 26.4 CLIVE SENSOR

OLEDs can draw icons, graphs and custom layouts. Check controller type, resolution, interface, voltage and library support. Small displays may use I²C or SPI.

Choosing an interface

DisplayGood forConsiderations
LED indicatorsSimple state and warningsLimited information; use resistors and suitable drivers.
Seven-segmentDigits, timers, countersSegment wiring, current, common type and multiplex refresh.
Character LCDText, menus, measurementsCharacter layout, contrast, backlight current and interface.
OLED / graphical LCDIcons, graphs and richer menusResolution, controller, memory use, interface and update rate.
07 · INTERACTIVE KEYPAD AND LCD

Try a small interface before wiring hardware

Use the simulated keypad to enter a short message. The LCD view updates as you type. This demonstrates input events and display feedback; it does not emulate electrical scanning, bounce or a physical LCD controller.

EazyLife STEM
Press a key...

Ready. Select keys to enter up to 16 characters.

08 · PRACTICAL BUILD

Build an Arduino keypad and LCD interface

Build a small local user interface: a 4×4 keypad accepts a four-digit demonstration code and a 16×2 I²C LCD provides prompts and feedback. This is a learning exercise in input handling, validation and display output, not a secure access-control product.

Components and equipment

  • Arduino Uno-compatible 5 V board.
  • 4×4 matrix membrane keypad.
  • 16×2 character LCD with compatible I²C backpack.
  • Breadboard or secure jumper connections.
  • USB cable and computer with Arduino IDE.
  • Optional small passive buzzer for feedback (through a suitable driver if required).

Connection map

ModulePinArduino Uno
Keypad rowsR1, R2, R3, R4D9, D8, D7, D6
Keypad columnsC1, C2, C3, C4D5, D4, D3, D2
I²C LCDVCC / GND5 V / GND (verify backpack rating)
I²C LCDSDA / SCLA4 / A5 on classic Uno R3

Uno R3 uses A4/A5 for I²C. Other boards may use different pins or logic voltages. Check your board and LCD backpack before connecting.

Arduino sketch

Install a compatible Keypad library and LiquidCrystal_I2C library. Many LCD backpacks use address 0x27 or 0x3F, but scan or verify the actual address. Library APIs differ; adjust the LCD initialisation calls if your chosen library uses a different interface.

#include <Wire.h>
#include <Keypad.h>
#include <LiquidCrystal_I2C.h>

const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};

byte rowPins[ROWS] = {9, 8, 7, 6};
byte colPins[COLS] = {5, 4, 3, 2};

Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
LiquidCrystal_I2C lcd(0x27, 16, 2);

const char demoCode[] = "2580";
char entered[5] = "";
byte enteredLength = 0;

void showPrompt() {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("ENTER DEMO CODE");
  lcd.setCursor(0, 1);
  for (byte i = 0; i < enteredLength; i++) lcd.print('*');
  for (byte i = enteredLength; i < 4; i++) lcd.print('_');
}

void clearEntry() {
  enteredLength = 0;
  entered[0] = '\0';
  showPrompt();
}

void checkEntry() {
  entered[enteredLength] = '\0';
  lcd.clear();
  lcd.setCursor(0, 0);
  if (strcmp(entered, demoCode) == 0) {
    lcd.print("DEMO ACCEPTED");
    lcd.setCursor(0, 1);
    lcd.print("Welcome!");
  } else {
    lcd.print("NOT A MATCH");
    lcd.setCursor(0, 1);
    lcd.print("Try again");
  }
  delay(1200);
  clearEntry();
}

void setup() {
  lcd.init();       // Some library versions use lcd.begin(16, 2)
  lcd.backlight();
  showPrompt();
}

void loop() {
  char key = keypad.getKey();
  if (!key) return;

  if (key == '*') {
    clearEntry();
  } else if (key == '#') {
    if (enteredLength == 4) checkEntry();
    else {
      lcd.setCursor(0, 1);
      lcd.print("Need 4 digits   ");
    }
  } else if (key >= '0' && key <= '9') {
    if (enteredLength < 4) {
      entered[enteredLength++] = key;
      entered[enteredLength] = '\0';
      showPrompt();
    }
  }
}

The fixed code is visible in the example firmware for learning only. Do not use this sketch or a hard-coded PIN for a real lock, alarm, payment terminal or security system. Real systems need secure credential handling, rate limiting, tamper resistance and an appropriate threat model.

Build and test

  1. With power disconnected, identify the keypad row/column ribbon order using its datasheet or continuity checks.
  2. Connect the keypad rows and columns to the assigned digital pins.
  3. Connect the LCD backpack to the correct supply and I²C pins. Confirm its voltage compatibility.
  4. Install the two libraries and verify the LCD I²C address. Adjust the constructor if needed.
  5. Upload the sketch. Confirm the LCD displays the prompt.
  6. Enter 2580 and press #. Observe the accepted message.
  7. Enter another four-digit value and press #. Observe the rejection message.
  8. Press * to clear the entry at any time.

Expected behaviour and troubleshooting

  • LCD blank: check supply, ground, contrast trimmer, I²C address and library initialisation.
  • Blocks or symbols: check contrast, display dimensions, backpack compatibility and power.
  • Wrong keys: verify keypad row/column order and the keys array.
  • Repeated key events: review keypad library debounce and hold settings.
  • Random characters: check wiring, common ground, supply stability and loose ribbon connections.
  • Uno upload or serial conflict: ensure the keypad wiring does not use the board's USB serial pins 0/1.

Extension challenges: add a menu with A/B navigation, show a sensor reading, add a buzzer confirmation, replace the LCD with an OLED, or use a rotary encoder. Keep input handling responsive and avoid long blocking delays in more advanced interfaces.

09 · INTERFACE DESIGN

Make the interaction understandable

Design principles

  • Use clear labels and predictable key actions.
  • Give immediate feedback after important inputs.
  • Distinguish success, warning and error states.
  • Provide a simple way to cancel or correct an entry.
  • Do not rely on colour alone to communicate status.
  • Consider display readability, viewing angle, contrast and text size.
  • Use timeouts and safe defaults where appropriate.

Reliability and accessibility

  • Validate inputs before acting on them.
  • Handle empty, incomplete and out-of-range entries.
  • Debounce physical controls and manage key repeats.
  • Keep menus consistent and avoid surprising mode changes.
  • Provide audible or tactile feedback only where appropriate.
  • Never expose passwords or sensitive data unnecessarily.
  • Consider how the interface behaves during power loss or sensor faults.
10 · KNOWLEDGE CHECK

Check what you understand

1. What is the main purpose of a current-limiting resistor on a bare seven-segment LED?

2. In a common-anode display, how is a segment normally turned ON?

3. Why does a matrix keypad use row and column scanning?

4. What is a useful role of an LCD or OLED in an embedded system?

KEEP LEARNING · GO FURTHER

Free to learn. More support when you need it.

Explore these open lessons at your own pace. For personalised explanations, project-specific troubleshooting, guided practical training or masterclasses, EazyLife offers paid support tailored to your learning goals.

Free or sponsored lesson referrals may be available through active programmes; they are not guaranteed.

Enquire about guidance