You are currently viewing 4×4 Keypad Library for Proteus: Free Membrane Keypad
4x4 Keypad Library for Proteus

4×4 Keypad Library for Proteus: Free Membrane Keypad

This free keypad library for Proteus adds the flat 4×4 membrane keypad to Proteus 8: the black keypad with 16 keys (0 to 9, A to D, * and #) and the 8-pin ribbon that comes in every Arduino kit. It has the real pins (R1 to R4, C1 to C4), and you press the keys with the mouse while the simulation runs.

Proteus has its own phone and calculator keypads, but not this one, and they do not behave like the membrane keypad on your desk. This 4×4 keypad Proteus model has 16 real contacts in a 4 x 4 matrix, so your Arduino sketch scans it exactly as on the bench with the Keypad library. You can hold several keys at once and see the real ghost keys, and even add contact bounce to test your debounce code.

In short

With the keypad library for Proteus installed, place 4X4 MEMBRANE KEYPAD, wire R1 to R4 and C1 to C4 to eight Arduino pins (no resistors needed), and run. Hold the left mouse button on a key to press it. Ctrl + click keeps a key down, so you can press several keys together.

Keypad library for Proteus: 4x4 membrane keypad
Figure: The 4x4 membrane keypad Proteus Model.

Keypad Library for Proteus: Features

Feature4×4 keypad Proteus model
Part4X4 MEMBRANE KEYPAD: the black membrane keypad with 16 keys and the 8-pin ribbon
Real key matrix16 contacts between 4 row and 4 column pins, about 100 ohm when pressed and open when released, like the real membrane. No diodes, no hidden logic
Clickable keysHold the left mouse button on a key: it stays pressed while you hold it, and the key picture goes down. Slide to another key and the press moves with you
Several keys at onceCtrl + click keeps a key down until you click it again, so you can test key combinations and the Keypad library’s multi-key mode
Ghost keysHold three keys at the corners of a rectangle and the Arduino also sees the fourth one, exactly like the real keypad
Contact bounceSet the bounce time to a few milliseconds and every press and release bounces like a real contact. Leave it at 0 for clean edges
No missed clicksA very quick click is held for at least 50 ms of simulation time, so a slow loop() still sees it
WarningsTwo driven pins shorted through a key, or more than 24 V on the keypad: a warning in the Proteus log says what to change
BoardsArduino UNO, Nano, Mega, ESP32 and any other microcontroller that scans a key matrix

4x4 Keypad Proteus Model: Pins and Wiring

Keypad pinKeys on itArduino UNO (example below)
R1Row 1: 1 2 3 AD9
R2Row 2: 4 5 6 BD8
R3Row 3: 7 8 9 CD7
R4Row 4: * 0 # DD6
C1Column 1: 1 4 7 *D5
C2Column 2: 2 5 8 0D4
C3Column 3: 3 6 9 #D3
C4Column 4: A B C DD2

The pins are in the same order as the ribbon of the real keypad, left to right with the keys facing you. The keypad needs no power and no resistors: the Keypad library turns on the Arduino’s internal pull-ups on the rows and pulls one column LOW at a time.

How the Arduino reads the keypad

All rows read HIGH through the pull-ups. The Arduino pulls column C1 LOW and reads the rows: if R2 is now LOW, key 4 (row 2, column 1) is pressed. Then C2, C3 and C4, many times a second. This is called scanning, and the keypad library for Proteus gives the Arduino the same voltages as the real keypad.

Example: Arduino Keypad Door Lock in Proteus

This Arduino keypad Proteus example reads the 4×4 keypad with an Arduino UNO. It is a small door lock that shows the code as stars on a Virtual Terminal: type 1 2 3 4 and then #, and a 12 V solenoid lock pulls in for 3 seconds. * clears the code.

The lock is the SOLENOID DEVICE from our solenoid library for Proteus: a real 12 V, 0.4 A coil. An Arduino pin can only give about 20 mA, so a relay module switches it.

  1. Place 4X4 MEMBRANE KEYPAD, an Arduino UNO, a relay module, a SOLENOID DEVICE, a 1N4007 diode, a 12 V DC supply and a Virtual Terminal.
  2. Wire R1 to R4 to D9, D8, D7, D6 and C1 to C4 to D5, D4, D3, D2, as in the table above.
  3. Relay module: VCC to 5 V, GND to GND, IN to D10.
  4. Solenoid: 12 V supply + to the relay COM, relay NO to the solenoid +, solenoid – to the 12 V GND. Put the 1N4007 across the coil, cathode to +.
  5. Terminal RX on the UNO TX (9600 baud). The UNO’s own L LED (D13) lights while the lock is open.
  6. In the Arduino IDE, install the Keypad library by Mark Stanley and Alexander Brevig (Tools → Manage Libraries, search keypad).
Keypad_Test.inoArduino
// 4x4 membrane keypad test for the ElectronicsTree Proteus model (ETKEYPAD.DLL)
//
// Circuit (Arduino UNO), keypad ribbon left to right:
//   R1 -> D9, R2 -> D8, R3 -> D7, R4 -> D6      (rows: INPUT_PULLUP, Keypad.h reads them)
//   C1 -> D5, C2 -> D4, C3 -> D3, C4 -> D2      (columns: pulled LOW one at a time)
//   No resistors needed on the keypad.
//   Lock: SOLENOID DEVICE (ElectronicsTree solenoid library, 12 V coil, 0.4 A) through a relay module
//     Relay module: VCC -> 5 V, GND -> GND, IN -> D10
//     12 V supply + -> relay COM, relay NO -> solenoid +, solenoid - -> 12 V GND
//     1N4007 across the solenoid coil, cathode to +
//   The UNO's own L LED (D13) lights while the lock is open.
//   Virtual Terminal on TX (9600 baud).
//

#include <Keypad.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
);

const int LOCK = 10;
const int LED = 13;

const int RELAY_ON = HIGH;
const int RELAY_OFF = LOW;

const char SECRET[] = "1234";

char code[9];
byte len = 0;

unsigned long lockOff = 0;


void enterKey(char k) {

  if (k == '*') {
    if (len > 0) Serial.println();        // end the star line
    len = 0;
    Serial.println(F("Password cleared"));
    return;
  }

  if (k == '#') {

    code[len] = '\0';

    Serial.println();

    if (len > 0 && strcmp(code, SECRET) == 0) {

      Serial.println(F("ACCESS GRANTED"));
      Serial.println(F("Lock: UNLOCKED (3 seconds)"));

      digitalWrite(LOCK, RELAY_ON);
      digitalWrite(LED, HIGH);

      lockOff = millis() + 3000;
    }
    else {

      Serial.println(F("ACCESS DENIED"));
      Serial.println(F("Lock: LOCKED"));
    }

    Serial.println();

    len = 0;
    return;
  }

  if (len >= sizeof(code) - 1) return;   // code full: ignore extra keys

  if (len == 0) Serial.print(F("Password: "));

  code[len++] = k;
  Serial.print('*');                      // one star per key, same line
}


void setup() {

  Serial.begin(9600);

  digitalWrite(LOCK, RELAY_OFF);
  pinMode(LOCK, OUTPUT);

  pinMode(LED, OUTPUT);

  keypad.setHoldTime(1000);

  Serial.println();
  Serial.println(F("================================"));
  Serial.println(F("       KEYPAD DOOR LOCK"));
  Serial.println(F("================================"));
  Serial.println(F("Enter password and press #"));
  Serial.println(F("Press * to clear password"));
  Serial.println(F("Lock: LOCKED"));
  Serial.println();
}


void loop() {

  if (lockOff && millis() > lockOff) {

    digitalWrite(LOCK, RELAY_OFF);
    digitalWrite(LED, LOW);

    lockOff = 0;

    Serial.println();
    Serial.println(F("Lock: LOCKED"));
    Serial.println();
  }

  if (!keypad.getKeys()) return;

  for (int i = 0; i < LIST_MAX; i++) {

    if (!keypad.key[i].stateChanged) continue;

    if (keypad.key[i].kstate == PRESSED) {
      enterKey(keypad.key[i].kchar);
    }
  }
}

Export the .hex file (Sketch → Export Compiled Binary), load it into the UNO and press Play. As you type the code, the terminal shows one star per key on a single line (Password: ****), so the code itself is never shown. Press * to clear what you typed. Type 1234#: the terminal shows ACCESS GRANTED, the relay clicks on, the solenoid pulls in and the L LED lights. After 3 seconds the lock closes again and the terminal shows Lock: LOCKED. A wrong code shows ACCESS DENIED and the lock stays shut. Many real relay boards switch on when their input is LOW. For those, set RELAY_ON to LOW.

New to simulating an Arduino? Our Arduino UNO R3 library for Proteus shows how to load a sketch, and the virtual serial terminal shows the messages.

Arduino 4x4 keypad door lock with a solenoid lock in Proteus
Figure: Arduino UNO with the 4x4 keypad, a relay module and a 12 V solenoid lock in Proteus.
Try it: ghost keys

While the simulation runs, Ctrl + click the keys 1, 2 and 4 so they stay down. The terminal shows four stars, not three: the fourth is 5, a key nobody pressed. 1, 2 and 4 sit on three corners of a rectangle in the matrix, and together they connect row 2 to column 2 as if 5 were pressed. Real membrane keypads have no diodes, so they do the same. Click the keys again to let them go.

Keypad Library for Proteus: Properties

Double-click the keypad to change it:

PropertyWhat it doesDefault
Contact Bounce (ms)Each press and release bounces for this time, like a real contact. 5 is realistic, and the Keypad library debounces 10 ms. 0 = clean edges0
Shortest Press Seen (ms)A quick click is held at least this long in the simulation, so the sketch never misses it. 0 = exactly as clicked50

Under Advanced Properties: the resistance of a pressed key (100 ohm) and of an open key (100 Mohm).

4x4 Keypad Proteus Troubleshooting

If the Arduino reads nothing or the wrong key, check these first. The keypad library for Proteus also writes a warning in the simulation log for wiring mistakes.

What you seeCause and fix
The key goes down, the sketch reads nothingThe row and column pins in the sketch do not match the wiring. Rows go in rowPins, columns in colPins
Wrong key, e.g. 4 instead of 2Rows and columns swapped, or the pin order reversed. Compare with the pin table above
Clicking a key does nothingThe simulation is not running (keys only work while it runs), or the click is not on a key
An extra key that you did not pressA ghost key: three held keys on the corners of a rectangle. Normal for a keypad without diodes
One click gives several pressesContact bounce is on and the sketch does not debounce. Use the Keypad library (it debounces), or set Contact Bounce to 0
“shorted through the key” warningTwo pins drive opposite levels through a pressed key. Rows must be inputs with pull-ups, and only one column LOW at a time

Download the Keypad Library for Proteus

The zip file of the keypad library for Proteus holds the model ETKEYPAD.DLL and the library ElectronicsTree[KEYPAD].LIB with the part 4X4 MEMBRANE KEYPAD.

Download
0 Downloads

Installing it takes two minutes (see the steps right below). Looking for more parts? Browse all our free Proteus libraries.

We’re always looking to expand our library collection based on what our community needs. If you’re looking for a specific Arduino module, sensor, or component that we don’t currently offer, we’d love to hear from you!

Reach out to us at help@electronicstree.com with your requests. We prioritize new library development based on community demand, so your suggestion could be our next addition.

Join the official WhatsApp channel of ElectronicsTree to stay updated with the latest electronics tutorials, Proteus libraries, Arduino projects, and simulation resources.

How to Install the Keypad Library for Proteus 8

New to adding libraries? Our guide how to install a library in Proteus 8 shows where the Proteus folders are.

  1. Close Proteus.
  2. Copy the files into the Proteus data folder, normally C:\Program Files (x86)\Labcenter Electronics\Proteus 8 Professional\DATA
    • ETKEYPAD.DLL goes into DATA\MODELS
    • ElectronicsTree[KEYPAD].LIB goes into DATA\LIBRARY
    Windows asks for administrator rights because the folder is under Program Files: click Continue.
  3. Start Proteus, open Pick Devices (press P) and search for membrane keypad. The part is in the category Sensor and Modules.
Tested with 8.17 SP2

The keypad library for Proteus is a library, not Proteus itself: the software comes from Labcenter Electronics, who also offer a free demo on their website.

Frequently Asked Questions

Is there a 4x4 keypad library for Proteus?

Yes. This free keypad library for Proteus adds the 4×4 membrane keypad with the 8-pin ribbon to Proteus 8, with 16 real contacts and keys you click with the mouse.

How do I connect a 4x4 keypad to an Arduino in Proteus?

Wire the four row pins R1 to R4 and the four column pins C1 to C4 to eight Arduino pins and list them in rowPins and colPins of the Keypad library. No resistors and no power pins are needed.

How do I press a key in the Proteus simulation?

Start the simulation and hold the left mouse button on the key. Ctrl + click keeps a key pressed until you click it again.

Can I press two keys at the same time?

Yes. Ctrl + click the keys you want to hold. The Keypad library reads up to 10 keys at once with getKeys().

Why does my Arduino see a key I did not press?

That is a ghost key. With three keys held on the corners of a rectangle, the fourth corner is connected too. Real membrane keypads do the same, and the 4×4 keypad Proteus model shows it.

Does the keypad work with an ESP32 in Proteus?

Yes. The keypad is only switches, so it works with any board and any logic level, including 3.3 V ESP32 pins.

Is this keypad Proteus library free?

Yes. Download the keypad library for Proteus from this page. The zip holds the model DLL and the library.

More Libraries for Proteus

Like the keypad library for Proteus? Try these next:

Conclusion

This keypad library for Proteus lets you build and test your Arduino keypad project before the hardware is on the desk: a 4×4 membrane keypad with 16 real contacts, keys you press with the mouse, several keys at once with real ghost keys, optional contact bounce and warnings for wiring mistakes.

Questions, or a module you want next? Write them in the comments!

Leave a Reply