Using a Keypad and LCD with Arduino to Store Cell Numbers(Arrays)
- Cartell Automotive
- Jun 24
- 2 min read
If you're starting out with Arduino and want a fun, real-world project to grow your skills, this one's for you. In this tutorial, we'll build a simple system using an LCD and a keypad to type in and store South African cellphone numbers. This is a great way to learn about arrays, user input, and memory limitations on microcontrollers.
What Is an Array?
An array is like a shelf with labeled boxes. Each box can store a value, and you can find the value by knowing its position (called the index). In Arduino, arrays let you hold multiple pieces of data (like a list of phone numbers) all under one variable name.
Example:
String phoneNumbers[5]; // Can hold 5 phone numbersSouth African mobile numbers are usually 10 digits long (e.g., 0821234567), and they always start with a 0. This makes input validation simple.
We’ll use:
A 4x4 keypad for input (digits 0–9 and a few control keys like * and #)
A 16x2 LCD to show the input
An array to store multiple cellphone numbers
Memory Consideration – How Many Can We Store?
Let’s break it down for a typical Arduino Uno:
SRAM (runtime memory): 2 KB
Each phone number (as a String) = ~11 bytes (10 digits + null terminator)
Assume 15 bytes per number to be safe (Strings can cause memory fragmentation)
Rough Estimate:
2048 bytes / 15 bytes per number ≈ 136 phone numbersUsing char arrays instead of String objects is more memory-efficient. But for beginner-friendliness, we’ll use String.
What You’ll Need
Component | Quantity |
Arduino Uno/Nano | 1 |
4x4 Matrix Keypad | 1 |
16x2 LCD + I2C | 1 |
Jumper wires | ~10 |
Breadboard | 1 |
Wiring Overview
Keypad → Digital pins (2–9)
LCD (via I2C) → A4 (SDA), A5 (SCL) on Uno
LCD needs 5V and GND
Sample Code here:
#include <Keypad.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
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);
String phoneNumbers[100]; // Store up to 100 numbers
String currentNumber = "";
int numberIndex = 0;
void setup() {
lcd.init();
lcd.backlight();
lcd.print("Enter number:");
}
void loop() {
char key = keypad.getKey();
if (key) {
if (key >= '0' && key <= '9') {
currentNumber += key;
lcd.setCursor(0, 1);
lcd.print(currentNumber);
}
else if (key == '#')
{ // Save number
if (currentNumber.length() == 10) {
phoneNumbers[numberIndex] = currentNumber;
numberIndex++;
lcd.clear();
lcd.print("Saved:");
lcd.setCursor(0,1);
lcd.print(currentNumber);
} else {
lcd.clear();
lcd.print("Invalid number");
}
currentNumber = "";
delay(1500);
lcd.clear();
lcd.print("Enter number:");
} else if (key == '*') { // Reset
currentNumber = "";
lcd.setCursor(0, 1);
lcd.print(" ");
}
}
}Use # to save the number.
Use * to clear the input.
Use 10 digits per entry to match valid South African mobile formats.

This project is an excellent intro to arrays, input devices, and display modules. With careful memory management, you can easily store up to 100 numbers on an Arduino Uno—and even more with other boards like the Mega or ESP32.




Comments