library 下載網址:http://cnlearn.linksprite.com/wp-content/uploads/2014/03/keypad.zip
程式碼:
[javascript]
#include <Keypad.h>
const byte ROWS = 4;
const byte COLS = 4;
//define the symbols on the buttons of the keypads
char Keys[ROWS][COLS] =
{
{‘1′,’2′,’3′,’A’},
{‘4′,’5′,’6′,’B’},
{‘7′,’8′,’9′,’C’},
{‘*’,’0′,’#’,’D’}
};//以上 4×4 陣列可自訂成你要的字元
byte rowPins[ROWS] = {2,3,4,5};//列腳位
byte colPins[COLS] = {6,7,8,9};//行腳位
//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad(makeKeymap(Keys),rowPins,colPins,ROWS,COLS);
void setup()
{
Serial.begin(9600);//開啟序列
Serial.println("Please press the keyboard:");
}
void loop()
{
char key = customKeypad.getKey();
if(key!=NO_KEY)
{
Serial.print("Key Value : ");
Serial.println(key);//印出所按下的字元
}
}
[/javascript]
原文網址:
http://learn.linksprite.com/arduino/4×4-keyboard-for-arduino/
[ Arduino ] – 4×4 薄膜鍵盤
評等結果
點擊便能為這篇文章進行評等!
[評等總次數: 0,平均評等: 0]
評等結果
點擊便能為這篇文章進行評等!
[評等總次數: 0,平均評等: 0]