Cov txheej txheem:

Keypad Access 4x4 Nrog Arduino: 5 Kauj Ruam (nrog Duab)
Keypad Access 4x4 Nrog Arduino: 5 Kauj Ruam (nrog Duab)

Video: Keypad Access 4x4 Nrog Arduino: 5 Kauj Ruam (nrog Duab)

Video: Keypad Access 4x4 Nrog Arduino: 5 Kauj Ruam (nrog Duab)
Video: How to use Arduino 4x4 keypad download the code 2024, Kaum ib hlis
Anonim
Keypad Access 4x4 Nrog Arduino
Keypad Access 4x4 Nrog Arduino

Lub 4x4 keypad yog sib xyaw ntawm 16 tus yuam sij tau teeb tsa zoo li cov lej. Txoj hauv kev siv rau nkag mus 4x4 cov keyboard nrog matrix scanning method. Lub 4x4 keypad xav kom 8 tus pin nkag mus rau nws, piv txwv li 4 tus pin rau kab thiab 4 tus pin rau kab. Yuav ua li cas txoj kev ntsuas ntsuas ua haujlwm yog tias tus lej kem siv LOW logic sib pauv, tom qab ntawv kab ntawv ua tiav qhov nyeem ib yam thiab.

Kauj Ruam 1: Cov Khoom Uas Koj Xav Tau

Koj yuav xav tau:

  • Arduino
  • Keypad 4 x 4
  • Jumper Hlau

Kauj ruam 2: Pin Out

  1. PIN A3 tus pin rau 0 kab
  2. PIN A2 tus pin rau 1 kab
  3. PIN A1 tus pin rau 2 kab
  4. PIN A0 tus pin rau 3 kab
  5. PIN 4 pin to 0 colomn
  6. PIN 5 pin to 1 colomn
  7. PIN 6 pin to 2 colomn
  8. PIN 7 pin to 3 colomn

Kauj ruam 3: Schematic

Schematic
Schematic
Schematic
Schematic

Txuas txhua feem raws li daim duab saum toj no.

Kauj ruam 4: Code

#suav nrog // ntshuam lub tsev qiv ntawv keyboard

const byte ROWS = 4; // tooj ntawm colomn

const byte COLS = 4; // tus naj npawb ntawm kab char hexaKeys [ROWS] [COLS] = {{'1', '2', '3', 'A'}, {'4', '5', '6', 'B'}, {'7', '8', '9', 'C'}, {'*', '0', '#', 'D'}}; byte rowPins [ROWS] = {A3, A2, A1, A0}; // tus pin siv rau kab byte colPins [COLS] = {4, 5, 6, 7}; // tus pin siv rau colomn

// initialization kuj sib txawv thiab

Keypad customKeypad = Keypad (uaKeymap (hexaKeys), rowPins, colPins, ROWS, COLS);

void teeb tsa () {

Serial.begin (9600); } void loop () {char customKey = customKeypad.getKey (); yog (customKey) {Serial.println (customKey); }}

Kauj Ruam 5: Tso Tawm

Tso zis
Tso zis

Txheeb xyuas qhov tso tawm!

Pom zoo: