Werktags vor 14:00 Uhr bestellt = am selben Tag versendet 30 Tage Widerrufsrecht 1 Jahr Garantie
← Zurück zur Übersicht

Schaltplan und Codebeispiel

So schließt du den 4x4 Matrix-Tastenfeld schwarz an einen Arduino UNO oder ESP32 an, mit einem Beispiel-Sketch, den du direkt hochladen kannst.

4x4-Matrix-Keypad-Eingabeleser

Dieses Projekt zeigt, wie man Eingaben von einem 4x4-Matrix-Keypad mit einem Arduino Uno ausliest. Wenn eine Taste auf dem Keypad gedrückt wird, wird das entsprechende Zeichen direkt im Serial Monitor mit 115200 baud ausgegeben.

Anschlussplan: 4x4 Matrix-Tastenfeld schwarz an einem Arduino UNO
Anschlussplan · Zum Vergrößern klicken
Anschlusstabelle: 4x4 Matrix-Tastenfeld schwarz an einem Arduino UNO
Anschlusstabelle · Zum Vergrößern klicken
4x4_Matrix_Keypad_Input_Reader.ino · kompiliert und getestet
/*
 * ==================================================================
 *  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);
  }
}

Benötigte Bibliotheken: Keypad 3.1.1

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

ESP32 4x4-Matrix-Tastenfeldleser

Diese Schaltung verbindet ein 4x4-Matrix-Tastenfeld direkt mit den GPIOs des ESP32. Die Keypad library scannt die Matrixzeilen und -spalten mithilfe interner Pull-up-Widerstände. Beim Drücken einer Taste wird ihr Zeichen in Echtzeit im Serial Monitor ausgegeben.

Anschlussplan: 4x4 Matrix-Tastenfeld schwarz an einem ESP32 DevKit V1
Anschlussplan · Zum Vergrößern klicken
Anschlusstabelle: 4x4 Matrix-Tastenfeld schwarz an einem ESP32 DevKit V1
Anschlusstabelle · Zum Vergrößern klicken
ESP32_4x4_Matrix_Keypad_Reader.ino · kompiliert und getestet
/*
 * ==================================================================
 *  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);
  }
}

Benötigte Bibliotheken: Keypad 3.1.1

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

Zuletzt angesehen

Zweirad ferngesteuertes Auto DIY

Zweirad ferngesteuertes Auto DIY

€ 15,60
Ansehen
8 Pin DIP IC-Socket

8 Pin DIP IC-Socket

€ 0,35
8x AA Batteriehalter (Back-To-Back 12V)

8x AA Batteriehalter (Back-To-Back 12V)

€ 1,70
Relaismodul 5v Low | 6-Kanal

Relaismodul 5v Low | 6-Kanal

€ 4,95
Rad mit Gummi für Roboter oder Smart Car Schwarz

Rad mit Gummi für Roboter oder Smart Car Schwarz

€ 2,10