Thông số kỹ thuật:
- Module bàn phím ma trận 3x4 loại phím mềm.
- Độ dài cáp: 88mm.
- Nhiệt độ hoạt động 0 ~ 70oC.
- Đầu nối ra 7 chân.
- Kích thước bàn phím 76.9 x 69.2 mm
Sơ đồ chân:
Code tham khảo Arduino:
//3x4 Arduino // 1 - 2 // 2 - 3 // 3 - 4 // 4 - 5 // 5 - 6 // 6 - 7 // 7 - 8 //Nạp code mở Serial Monitor chọn No line ending, baud 9600. #include "Keypad.h" const byte Rows= 4; //number of rows on the keypad i.e. 4 const byte Cols= 3; //number of columns on the keypad i,e, 3 //we will definne the key map as on the key pad: char keymap[Rows][Cols]= { {'1', '2', '3'}, {'4', '5', '6'}, {'7', '8', '9'}, {'*', '0', '#'} }; byte rPins[Rows]= {8,7,6,5}; //Rows 0 to 3 byte cPins[Cols]= {4,3,2}; //Columns 0 to 2 // command for library forkeypad //initializes an instance of the Keypad class Keypad kpd= Keypad(makeKeymap(keymap), rPins, cPins, Rows, Cols); void setup() { Serial.begin(9600); // initializing serail monitor } //If key is pressed, this key is stored in 'keypressed' variable //If key is not equal to 'NO_KEY', then this key is printed out void loop() { char keypressed = kpd.getKey(); if (keypressed != NO_KEY) { Serial.println(keypressed); } }
Video tham khảo: