本帖最後由 zonebaby 於 2010-5-22 17:36 編輯
用番Arduino個Matrix Keypad library試下。個library可以係依度搵倒。
http://www.arduino.cc/playground/Main/KeypadTutorial
將個library放係..\libraries下便就可以用倒。
再改下個附帶既例子HelloKeypad試下。
打開個code睇下,原來都好易改,就係改左依幾句,
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'#','0','*'}
};
byte rowPins[ROWS] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {8, 7, 6}; //connect to the column pinouts of the keypad
變成依幾句,去配合個matrix keypad既matrix大小,按鍵字符,同埋接口既pin no。
const byte ROWS = 4; //four rows
const byte COLS = 4; //three columns
char keys[ROWS][COLS] = {
{'1','2','3','+'},
{'4','5','6','-'},
{'7','8','9','*'},
{'=','0','.','/'}
};
byte rowPins[ROWS] = {4,5,6,7}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {8,9,10,11}; //connect to the column pinouts of the keypad
compile完再upload就可以試下啱唔啱。
用ardiuno既serial monitor就睇郅個matrix keypad既輸出。
serial monitor
4×4 matrix keypad試機成功......
ps:加番張圖 |