Skip to main content

Raspberry Pi Pico Keypad LED Project – Blue LEDs for Numbers, Red LEDs for Letters | Beginner Tutorial

Raspberry Pi Pico Keypad LED Project | MakeMindz
Beginner Friendly Raspberry Pi Pico Free Simulation

4×4 Matrix Keypad LED Controller with Raspberry Pi Pico

Build an interactive LED panel that lights up blue LEDs for number keys and red LEDs for alphabet keys — all controlled from a 16-key matrix keypad. Includes full wiring, code, and a live Wokwi simulation.

📅 February 2026 ⏱ ~30 min build 🔧 12 LEDs · 4×4 Keypad · Pi Pico 🌐 makemindz.com
🧰

Components Required

🍓
Raspberry Pi Pico
⌨️
4×4 Matrix Keypad (16 keys)
💙
8× Blue LEDs (numbers 1–9)
❤️
4× Red LEDs (letters A–D)
〰️
Resistors (1× per LED, 220Ω)
🔌
Jumper Wires + USB Cable

How It Works

Number Keys 1–8

Each number key turns on its corresponding blue LED individually.

Key "9" — All Blue ON

Press 9 to light all 8 blue LEDs simultaneously.

Key "0" — Reset Blue

Pressing 0 turns off all blue LEDs at once.

Keys A, B, C, D

Each alphabet key lights up its matching red LED.

Key "*" — All Red ON

Press * to turn on all 4 red LEDs at once.

Key "#" — Reset Red

Pressing # clears all red LEDs simultaneously.

🎮 Try it Free — No Hardware Needed

Run this project in your browser using the Wokwi online simulator.

Launch Simulation
📍

GPIO Pin Mapping

🔵 Blue LEDs (GP2–GP11)
LED1(8)→GP11, LED2(7)→GP10
LED3(6)→GP9, LED4(5)→GP8
LED5(4)→GP7, LED6(3)→GP6
LED7(2)→GP5, LED8(1)→GP4
🔴 Red LEDs (GP2–GP3, GP27–GP28)
LED9(A) →GP3
LED10(B)→GP2
LED11(C)→GP28
LED12(D)→GP27
⌨️ Keypad Rows (GP20–GP26)
R1→GP26, R2→GP22
R3→GP21, R4→GP20
⌨️ Keypad Cols (GP16–GP19)
C1→GP19, C2→GP18
C3→GP17, C4→GP16
📋

Step-by-Step Instructions

1

Connect the 4×4 Keypad

The keypad has 8 pins — 4 rows and 4 columns. Connect all 8 pins to GPIO pins on the Pi Pico using green jumper wires. Row pins connect to GP26, GP22, GP21, GP20. Column pins connect to GP19, GP18, GP17, GP16. Add pull-down resistors on row lines to prevent floating signals.

2

Connect the Blue LEDs (Numbers 1–8)

Arrange 8 blue LEDs in a row. Place a 220Ω resistor in series with each LED to limit current. Wire the anodes (+) to GP4 through GP11 on the Pico. These LEDs represent keys 1–8. LED for key 8 connects to GP11, key 7 to GP10, and so on down to key 1 at GP4.

3

Connect the Red LEDs (A, B, C, D)

Place 4 red LEDs next to the blue row with 220Ω resistors in series. Wire LED-A to GP3, LED-B to GP2, LED-C to GP28, and LED-D to GP27. Connect all cathodes (−) to GND.

4

Connect Power and Ground

Connect the pull-down resistors for the keypad rows to the 3.3V pin (3V3) on the Pi Pico via a shared rail. Connect all LED cathodes and common grounds to any GND pin on the Pico.

5

Upload the Code

Copy the Arduino/C++ code below and upload it to your Raspberry Pi Pico using the Arduino IDE with the Pico board package installed. The Keypad.h library handles matrix scanning automatically.

6

Configure the Reset Keys

The code handles two special reset functions: pressing 0 turns off all 8 blue LEDs, and pressing # turns off all 4 red LEDs. Press 9 to light all blue LEDs, and * to light all red LEDs.

7

Test and Run

Power the Pico via USB. Press number keys 1–8 to toggle blue LEDs on. Press A–D to toggle red LEDs. Use 0 and # to reset each group. You can also test the full circuit online using the Wokwi simulation link below.

💻

Arduino Code

C++ / Arduino
#include <Keypad.h>

const uint8_t LEDS = 12;
const uint8_t ROWS = 4;
const uint8_t COLS = 4;

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

// Pins for LED1–LED12 (blue: 0–7, red: 8–11)
uint8_t ledPins[LEDS] = { 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 28, 27 };
uint8_t rowPins[ROWS] = { 26, 22, 21, 20 }; // R1–R4
uint8_t colPins[COLS] = { 19, 18, 17, 16 }; // C1–C4

Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);

void setup() {
  for (uint8_t l = 0; l < LEDS; l++) {
    pinMode(ledPins[l], OUTPUT);
    digitalWrite(ledPins[l], LOW);
  }
}

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

  if (key != NO_KEY) {
    switch (key) {
      case '1': digitalWrite(ledPins[0], HIGH); break;
      case '2': digitalWrite(ledPins[1], HIGH); break;
      case '3': digitalWrite(ledPins[2], HIGH); break;
      case '4': digitalWrite(ledPins[3], HIGH); break;
      case '5': digitalWrite(ledPins[4], HIGH); break;
      case '6': digitalWrite(ledPins[5], HIGH); break;
      case '7': digitalWrite(ledPins[6], HIGH); break;
      case '8': digitalWrite(ledPins[7], HIGH); break;
      case '9': // All blue LEDs ON
        for (uint8_t l = 0; l < 8; l++) digitalWrite(ledPins[l], HIGH);
        break;
      case '0': // Reset all blue LEDs
        for (uint8_t l = 0; l < 8; l++) digitalWrite(ledPins[l], LOW);
        break;
      case 'A': digitalWrite(ledPins[8],  HIGH); break;
      case 'B': digitalWrite(ledPins[9],  HIGH); break;
      case 'C': digitalWrite(ledPins[10], HIGH); break;
      case 'D': digitalWrite(ledPins[11], HIGH); break;
      case '*': // All red LEDs ON
        for (uint8_t l = 8; l < 12; l++) digitalWrite(ledPins[l], HIGH);
        break;
      case '#': // Reset all red LEDs
        for (uint8_t l = 8; l < 12; l++) digitalWrite(ledPins[l], LOW);
        break;
    }
  }
  delay(10);
}
🗺️

Wokwi Diagram JSON

How to use: Copy this JSON and paste it into the diagram.json file inside your Wokwi project. It defines all components, their positions, and every wire connection.
diagram.json
{
  "version": 1,
  "author": "Anderson Costa",
  "editor": "wokwi",
  "parts": [
    { "type": "wokwi-pi-pico", "id": "pico", "top": 118, "left": 348, "rotate": 90, "attrs": {} },
    { "type": "wokwi-resistor", "id": "rp1", "top": 349.55, "left": 19.2, "attrs": { "value": "1000" } },
    { "type": "wokwi-resistor", "id": "rp2", "top": 368.75, "left": 19.2, "attrs": { "value": "1000" } },
    { "type": "wokwi-resistor", "id": "rp3", "top": 426.35, "left": 19.2, "attrs": { "value": "1000" } },
    { "type": "wokwi-resistor", "id": "rp4", "top": 397.55, "left": 19.2, "attrs": { "value": "1000" } },
    { "type": "wokwi-membrane-keypad", "id": "keypad1", "top": -30.8, "left": -13.6, "attrs": {} },
    { "type": "wokwi-led", "id": "led1",  "top": 20, "left": 420, "attrs": { "color": "blue", "label": "8" } },
    { "type": "wokwi-resistor", "id": "r1",  "top": 90, "left": 415, "rotate": 90, "attrs": { "value": "220" } },
    { "type": "wokwi-led", "id": "led2",  "top": 20, "left": 400, "attrs": { "color": "blue", "label": "7" } },
    { "type": "wokwi-resistor", "id": "r2",  "top": 90, "left": 395, "rotate": 90, "attrs": { "value": "220" } },
    { "type": "wokwi-led", "id": "led3",  "top": 20, "left": 380, "attrs": { "color": "blue", "label": "6" } },
    { "type": "wokwi-resistor", "id": "r3",  "top": 90, "left": 375, "rotate": 90, "attrs": { "value": "220" } },
    { "type": "wokwi-led", "id": "led4",  "top": 20, "left": 360, "attrs": { "color": "blue", "label": "5" } },
    { "type": "wokwi-resistor", "id": "r4",  "top": 90, "left": 355, "rotate": 90, "attrs": { "value": "220" } },
    { "type": "wokwi-led", "id": "led5",  "top": 20, "left": 340, "attrs": { "color": "blue", "label": "4" } },
    { "type": "wokwi-resistor", "id": "r5",  "top": 90, "left": 335, "rotate": 90, "attrs": { "value": "220" } },
    { "type": "wokwi-led", "id": "led6",  "top": 20, "left": 320, "attrs": { "color": "blue", "label": "3" } },
    { "type": "wokwi-resistor", "id": "r6",  "top": 90, "left": 315, "rotate": 90, "attrs": { "value": "220" } },
    { "type": "wokwi-led", "id": "led7",  "top": 20, "left": 300, "attrs": { "color": "blue", "label": "2" } },
    { "type": "wokwi-resistor", "id": "r7",  "top": 90, "left": 295, "rotate": 90, "attrs": { "value": "220" } },
    { "type": "wokwi-led", "id": "led8",  "top": 20, "left": 280, "attrs": { "color": "blue", "label": "1" } },
    { "type": "wokwi-resistor", "id": "r8",  "top": 90, "left": 275, "rotate": 90, "attrs": { "value": "220" } },
    { "type": "wokwi-led", "id": "led9",  "top": 20, "left": 440, "attrs": { "color": "red",  "label": "A" } },
    { "type": "wokwi-resistor", "id": "r9",  "top": 90, "left": 435, "rotate": 90, "attrs": { "value": "220" } },
    { "type": "wokwi-led", "id": "led10", "top": 20, "left": 460, "attrs": { "color": "red",  "label": "B" } },
    { "type": "wokwi-resistor", "id": "r10", "top": 90, "left": 455, "rotate": 90, "attrs": { "value": "220" } },
    { "type": "wokwi-led", "id": "led11", "top": 20, "left": 480, "attrs": { "color": "red",  "label": "C" } },
    { "type": "wokwi-resistor", "id": "r11", "top": 90, "left": 475, "rotate": 90, "attrs": { "value": "220" } },
    { "type": "wokwi-led", "id": "led12", "top": 20, "left": 500, "attrs": { "color": "red",  "label": "D" } },
    { "type": "wokwi-resistor", "id": "r12", "top": 90, "left": 495, "rotate": 90, "attrs": { "value": "220" } }
  ],
  "connections": [
    [ "pico:GP0", "$serialMonitor:RX", "", [] ],
    [ "pico:GP1", "$serialMonitor:TX", "", [] ],
    [ "keypad1:C4", "pico:GP16", "green", [ "v15", "h132" ] ],
    [ "keypad1:C3", "pico:GP17", "green", [ "v25", "h182" ] ],
    [ "keypad1:C2", "pico:GP18", "green", [ "v35", "h204" ] ],
    [ "keypad1:C1", "pico:GP19", "green", [ "v45", "h222" ] ],
    [ "keypad1:R4", "pico:GP20", "green", [ "v55", "h240" ] ],
    [ "keypad1:R3", "pico:GP21", "green", [ "v65", "h260" ] ],
    [ "keypad1:R2", "pico:GP22", "green", [ "v75", "h286" ] ],
    [ "keypad1:R1", "pico:GP26", "green", [ "v85", "h299" ] ],
    [ "r1:1",  "led1:A",  "green", [ "h0" ] ],
    [ "r2:1",  "led2:A",  "green", [ "h0" ] ],
    [ "r3:1",  "led3:A",  "green", [ "h0" ] ],
    [ "r4:1",  "led4:A",  "green", [ "h0" ] ],
    [ "r5:1",  "led5:A",  "green", [ "h0" ] ],
    [ "r6:1",  "led6:A",  "green", [ "h0" ] ],
    [ "r7:1",  "led7:A",  "green", [ "h0" ] ],
    [ "r8:1",  "led8:A",  "green", [ "h0" ] ],
    [ "r9:1",  "led9:A",  "green", [ "h0" ] ],
    [ "r10:1", "led10:A", "green", [ "h0" ] ],
    [ "r11:1", "led11:A", "green", [ "h0" ] ],
    [ "r12:1", "led12:A", "green", [ "h0" ] ],
    [ "pico:GND.4", "led1:C",  "black", [ "v-25", "h-22", "v-77", "h6" ] ],
    [ "pico:GND.4", "led2:C",  "black", [ "v-25", "h-22", "v-77", "h6" ] ],
    [ "pico:GND.4", "led3:C",  "black", [ "v-25", "h-22", "v-77", "h6" ] ],
    [ "pico:GND.4", "led4:C",  "black", [ "v-25", "h-22", "v-77", "h6" ] ],
    [ "pico:GND.4", "led5:C",  "black", [ "v-25", "h-22", "v-77", "h6" ] ],
    [ "pico:GND.4", "led6:C",  "black", [ "v-25", "h-22", "v-77", "h6" ] ],
    [ "pico:GND.4", "led7:C",  "black", [ "v-25", "h-22", "v-77", "h6" ] ],
    [ "pico:GND.4", "led8:C",  "black", [ "v-25", "h-22", "v-77", "h6" ] ],
    [ "pico:GND.4", "led9:C",  "black", [ "v-25", "h-22", "v-77", "h6" ] ],
    [ "pico:GND.4", "led10:C", "black", [ "v-25", "h-22", "v-77", "h6" ] ],
    [ "pico:GND.4", "led11:C", "black", [ "v-25", "h-22", "v-77", "h6" ] ],
    [ "pico:GND.4", "led12:C", "black", [ "v-25", "h-22", "v-77", "h6" ] ],
    [ "pico:GP4",  "r1:2",  "green", [ "v-28", "h10",  "v-20" ] ],
    [ "pico:GP5",  "r2:2",  "green", [ "v-36", "h8"  ] ],
    [ "pico:GP6",  "r3:2",  "green", [ "v-26", "h7"  ] ],
    [ "pico:GP7",  "r4:2",  "green", [ "v-36", "h-3" ] ],
    [ "pico:GP8",  "r5:2",  "green", [ "v-33", "h-13"] ],
    [ "pico:GP9",  "r6:2",  "green", [ "v-23", "h-14", "v-11", "h-10" ] ],
    [ "pico:GP10", "r7:2",  "green", [ "v-22", "h-16", "v-9" ] ],
    [ "pico:GP11", "r8:2",  "green", [ "v-12", "h-17", "v-24", "h-18" ] ],
    [ "pico:GP3",  "r9:2",  "green", [ "v-20", "h10",  "v-20", "h20",  "v-13" ] ],
    [ "pico:GP2",  "r10:2", "green", [ "v-15", "h20",  "v-15", "h20",  "v-22" ] ],
    [ "pico:GP28", "r11:2", "green", [ "v155", "h104" ] ],
    [ "pico:GP27", "r12:2", "green", [ "v165", "h152" ] ],
    [ "rp1:2", "keypad1:R1", "green", [ "h8.4", "v-48" ] ],
    [ "rp2:2", "keypad1:R2", "green", [ "h18",  "v-67.2" ] ],
    [ "rp4:2", "keypad1:R3", "green", [ "h27.6","v-96" ] ],
    [ "rp3:2", "keypad1:R4", "green", [ "h37.2","v-124.8" ] ],
    [ "rp1:1", "rp2:1", "red", [ "v0" ] ],
    [ "rp2:1", "rp4:1", "red", [ "v0" ] ],
    [ "rp4:1", "rp3:1", "red", [ "v0" ] ],
    [ "rp3:1", "pico:3V3", "red", [ "v19.2", "h417.15" ] ]
  ],
  "dependencies": {}
}
🗂️

LED Mapping Summary

Key Pressed LED Color Action
1 – 8 Blue Lights matching blue LED
9 Blue All 8 blue LEDs ON
0 Blue Reset — all blue OFF
A, B, C, D Red Lights matching red LED
* Red All 4 red LEDs ON
# Red Reset — all red OFF

🔗 Open the Free Simulation

No hardware required. Click below to run the full project in Wokwi — press keys and watch the LEDs respond in real time.

Open in Wokwi
🚀

More Raspberry Pi Pico Projects

Comments

try for free