Codey OnlineLibreria di componenti Arduino ed ESP32 › Keypad 4x4
Keypad 4x4
Sensori

Keypad 4x4

Keypad con 4x4 pulsanti 123A 456B 789C *0#D

Larghezza: 64.5 mm

Pinout — Keypad 4x4

Pin Segnale Descrizione
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

Schema di cablaggio di esempio — Keypad 4x4

Da A Filo
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

Codice Arduino di esempio — Keypad 4x4

Questo esempio è stato scritto e verificato in compilazione per arduino-uno. Codey Online lo adatta a qualsiasi altra scheda supportata.

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

Componenti correlati

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

Crea il tuo progetto Arduino o ESP32 con l'AI

Descrivi cosa vuoi realizzare. Codey Online scrive il codice, disegna lo schema di collegamento, lo compila e programma la tua scheda direttamente dal browser.

Inizia gratis