Op werkdagen vóór 14:00 uur besteld = dezelfde dag verzonden en in 98% van de gevallen de volgende dag in huis. Gratis retourneren 30 dagen bedenktijd 1 jaar garantie
← Tillbaka till översikten

Kopplingsschema och kodexempel

Så här kopplar du 4x4 matris-knappsats svart till en Arduino UNO eller ESP32, med ett exempel­sketch som du kan ladda upp direkt.

4x4 Matrix Keypad Input Reader

This project demonstrates how to read inputs from a 4x4 matrix keypad using an Arduino Uno. When any button on the keypad is pressed, the corresponding character is printed directly to the Serial Monitor at 115200 baud.

Kopplingsschema: 4x4 matris-knappsats svart på en Arduino UNO
Kopplingsschema · Klicka för att förstora
Kopplingstabell: 4x4 matris-knappsats svart på en Arduino UNO
Kopplingstabell · Klicka för att förstora
4x4_Matrix_Keypad_Input_Reader.ino · kompilerad och testad
/*
 * ==================================================================
 *  Generated by Codey.online  —  https://www.codey.online
 * ==================================================================
 *  Project   : 4x4 Matrix Keypad Input Reader
 *  Board     : Arduino UNO (arduino:avr:uno)
 *  Parts     : Keypad 4x4
 *  Libraries : Keypad 3.1.1
 *
 *  Codey Online is an AI-powered browser IDE for Arduino and ESP32.
 *  Describe your project and Codey writes the code, draws the wiring
 *  diagram and uploads it to your board, straight from the browser.
 *  This code is free to use, modify and share, without warranty.
 * ==================================================================
 */

#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);

void setup() {
  Serial.begin(115200);
  Serial.println(F("4x4 Keypad Demo"));
  Serial.println(F("Press any key on the keypad..."));
}

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

  if (key) {
    Serial.print(F("Key Pressed: "));
    Serial.println(key);
  }
}

Nödvändiga bibliotek: Keypad 3.1.1

Wiring diagram and example code generated by Codey.online — https://www.codey.online

ESP32 4x4 Matrix Keypad Reader

This circuit connects a 4x4 matrix keypad directly to the ESP32 GPIOs. The Keypad library scans the matrix rows and columns using internal pull-up resistors. Pressing any key prints its character to the Serial Monitor in real time.

Kopplingsschema: 4x4 matris-knappsats svart på en ESP32 DevKit V1
Kopplingsschema · Klicka för att förstora
Kopplingstabell: 4x4 matris-knappsats svart på en ESP32 DevKit V1
Kopplingstabell · Klicka för att förstora
ESP32_4x4_Matrix_Keypad_Reader.ino · kompilerad och testad
/*
 * ==================================================================
 *  Generated by Codey.online  —  https://www.codey.online
 * ==================================================================
 *  Project   : ESP32 4x4 Matrix Keypad Reader
 *  Board     : ESP32 DEVKIT V1 (esp32:esp32:esp32doit-devkit-v1)
 *  Parts     : Keypad 4x4
 *  Libraries : Keypad 3.1.1
 *
 *  Codey Online is an AI-powered browser IDE for Arduino and ESP32.
 *  Describe your project and Codey writes the code, draws the wiring
 *  diagram and uploads it to your board, straight from the browser.
 *  This code is free to use, modify and share, without warranty.
 * ==================================================================
 */

#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] = {19, 18, 5, 4};
byte colPins[COLS] = {13, 12, 14, 27};

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

void setup() {
  Serial.begin(115200);
  Serial.println("4x4 Keypad Test Ready. Press any key...");
}

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

  if (customKey) {
    Serial.print("Key pressed: ");
    Serial.println(customKey);
  }
}

Nödvändiga bibliotek: Keypad 3.1.1

Wiring diagram and example code generated by Codey.online — https://www.codey.online

Tidigare visade

Velleman Reservspets 0.5mm, spetsformad

Velleman Reservspets 0.5mm, spetsformad

€ 2,95