Commandé avant 14h00 un jour ouvrable = expédié le jour même 30 jours de délai de rétractation Garantie d’un an
← Retour à l’aperçu

Schéma de câblage et exemple de code

Voici comment connecter le clavier matriciel 4x4 noir à un Arduino UNO ou à un ESP32, avec un exemple de sketch que tu peux téléverser directement.

Lecteur d'entrée pour clavier matriciel 4x4

Ce projet montre comment lire les entrées d’un clavier matriciel 4x4 à l’aide d’un Arduino Uno. Lorsqu’un bouton du clavier est enfoncé, le caractère correspondant s’affiche directement dans le Moniteur Série à 115200 baud.

Schéma de câblage : clavier matriciel 4x4 noir sur un Arduino UNO
Schéma de câblage · Cliquez pour agrandir
Tableau de câblage : clavier matriciel 4x4 noir sur un Arduino UNO
Tableau de câblage · Cliquez pour agrandir
4x4_Matrix_Keypad_Input_Reader.ino · compilé et testé
/*
 * ==================================================================
 *  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);
  }
}

Bibliothèques nécessaires : Keypad 3.1.1

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

Lecteur de clavier matriciel 4x4 pour ESP32

Ce circuit connecte directement un clavier matriciel 4x4 aux GPIO de l’ESP32. La Keypad library analyse les lignes et colonnes de la matrice à l’aide de résistances de pull-up internes. Lorsque vous appuyez sur une touche, son caractère s’affiche en temps réel dans le Serial Monitor.

Schéma de câblage : clavier matriciel 4x4 noir sur un ESP32 DevKit V1
Schéma de câblage · Cliquez pour agrandir
Tableau de câblage : clavier matriciel 4x4 noir sur un ESP32 DevKit V1
Tableau de câblage · Cliquez pour agrandir
ESP32_4x4_Matrix_Keypad_Reader.ino · compilé et testé
/*
 * ==================================================================
 *  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);
  }
}

Bibliothèques nécessaires : Keypad 3.1.1

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

Récemment consultés

Clavier matriciel 3x4 noir

Clavier matriciel 3x4 noir

€ 3,40