Codey OnlineBibliothèque de composants Arduino & ESP32 › Keypad 4x4
Keypad 4x4
Capteurs

Keypad 4x4

Clavier à 16 touches 123A 456B 789C *0#D

Largeur: 64.5 mm

Brochage — Keypad 4x4

Broche Signal Description
C1 digital Colimn 1
C2 digital Column 2
C3 digital Column 3
C4 digital Column 4
R1 digital Row 1
R2 digital Row 2
R3 digital Row 3
R4 digital Row 4

Exemple de schéma de câblage — Keypad 4x4

De Vers Fil
board:D9 x1:C1 green
board:D8 x1:C2 blue
board:D7 x1:C3 yellow
board:D6 x1:C4 purple
board:D5 x1:R1 cyan
board:D4 x1:R2 magenta
board:D3 x1:R3 brown
board:D2 x1:R4 pink

Exemple de code Arduino — Keypad 4x4

Cet exemple a été écrit et vérifié à la compilation pour le arduino-uno. Codey Online l'adapte pour vous à toute autre carte prise en charge.

#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] = {5, 4, 3, 2};
byte colPins[COLS] = {9, 8, 7, 6};

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

void setup() {
  Serial.begin(9600);
  while (!Serial) {
    ;
  }
  Serial.println("4x4 Keypad example");
  Serial.println("Press a key on the keypad to see it in the Serial Monitor.");
}

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

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

Composants similaires

18650 Battery Shield with USB-C Charger and 5V Boost Converter

18650 Battery Shield with USB-C Charger and 5V Boost Converter

2.4 inch OLED Display I2C 3.3V

2.4 inch OLED Display I2C 3.3V

3.5 inch TFT LCD Shield

3.5 inch TFT LCD Shield

50kg Load Cell Weight Sensor

50kg Load Cell Weight Sensor

Construisez votre projet Arduino ou ESP32 avec l'IA

Décrivez ce que vous voulez créer. Codey Online écrit le code, dessine le schéma de câblage, le compile et flashe votre carte directement depuis le navigateur.

Commencez gratuitement