Key map
This commit is contained in:
parent
d9416edfdd
commit
b5fabe2dca
BIN
Design/Layout.xlsx
Normal file
BIN
Design/Layout.xlsx
Normal file
Binary file not shown.
BIN
Design/~$Layout.xlsx
Normal file
BIN
Design/~$Layout.xlsx
Normal file
Binary file not shown.
46
firmware/keyboard/keyboard.ino
Normal file
46
firmware/keyboard/keyboard.ino
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
#include <Keypad.h>
|
||||||
|
|
||||||
|
const byte ROWS = 4; // Four rows
|
||||||
|
const byte COLS = 3; // Three columns
|
||||||
|
// Define the Keymap
|
||||||
|
char keys[ROWS][COLS] = {
|
||||||
|
{'1','2','3'},
|
||||||
|
{'4','5','6'},
|
||||||
|
{'7','8','9'},
|
||||||
|
{'#','0','*'}
|
||||||
|
};
|
||||||
|
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
|
||||||
|
byte rowPins[ROWS] = { 9, 8, 7, 6 };
|
||||||
|
// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
|
||||||
|
byte colPins[COLS] = { 12, 11, 10 };
|
||||||
|
|
||||||
|
// Create the Keypad
|
||||||
|
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
|
||||||
|
|
||||||
|
#define ledpin 13
|
||||||
|
|
||||||
|
void setup()
|
||||||
|
{
|
||||||
|
pinMode(ledpin,OUTPUT);
|
||||||
|
digitalWrite(ledpin, HIGH);
|
||||||
|
Serial.begin(9600);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop()
|
||||||
|
{
|
||||||
|
char key = kpd.getKey();
|
||||||
|
if(key) // Check for a valid key.
|
||||||
|
{
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
case '*':
|
||||||
|
digitalWrite(ledpin, LOW);
|
||||||
|
break;
|
||||||
|
case '#':
|
||||||
|
digitalWrite(ledpin, HIGH);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Serial.println(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user