ARDUINO KEYPAD4X4 KEYBOARD SERIAL
#2 SOURCE CODE EXPLAIN
27/3/2562 SONGCHAI
PRAPATRUNGSEE
ARDUINO KEYPAD4X4 KEYBOARD SERIAL
#2 SOURCE CODE EXPLAIN
รายการอุปกรณ์
/////////////////////////////////////////////////////////////////
#include <Keypad.h>
//2dimension array save the keypad
characters
char KEY[4][4] =
{
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte ROW[4]={9, 8, 7, 6};//CONNECT
ROW PINOUTS OF KEYPAD
byte COL[4]={5, 4, 3, 2};//CONNECT
COLUMN PINOUTS OF KEYPAD
/*In code, use Keypad class
provided by the Keypad library to operate keypad. The following is to
instantiate a keypad object, and
the last two parameter represents the number of the row and column of the
keypad*/
Keypad
KPAD=Keypad(makeKeymap(KEY),ROW,COL,4,4);
void setup()
{
Serial.begin(9600);//INITIALIZE SERIAL PORT.
SET BAUD RATE 9600
Serial.println("TEST
KEYPAD!");//PRINT "TEST KEYPAD!"
}
void loop()
{
char PRESS = KPAD.getKey();
if (PRESS)
{
Serial.print(PRESS);
}
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น