This commit is contained in:
Max Hunt 2018-09-27 14:14:51 +01:00
parent b5fabe2dca
commit e5ed98bae0

View File

@ -1,46 +1,109 @@
#include <Key.h>
#include <Keypad.h> #include <Keypad.h>
const byte ROWS = 4; // Four rows const byte ROWS = 4; // Four rows
const byte COLS = 3; // Three columns const byte COLS = 4; // Three columns
// Define the Keymap // Define the Keymap
char keys[ROWS][COLS] = { char keys[ROWS][COLS] = {
{'1','2','3'}, {'0','1','2','3'},
{'4','5','6'}, {'4','5','6','7'},
{'7','8','9'}, {'8','9','a','b'},
{'#','0','*'} {'c','d','e','f'}
}; };
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins. // Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = { 9, 8, 7, 6 }; byte rowPins[ROWS] = {13, 5, 10, 9};
// Connect keypad COL0, COL1 and COL2 to these Arduino pins. // Connect keypad COL0, COL1 and COL2 to these Arduino pins.
byte colPins[COLS] = { 12, 11, 10 }; byte colPins[COLS] = {8, 6, 12, 4};
// Create the Keypad // Create the Keypad
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS ); Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
#define ledpin 13 #define ledpin 11
void setup() void setup()
{ {
pinMode(ledpin,OUTPUT); pinMode(ledpin,OUTPUT);
digitalWrite(ledpin, HIGH); digitalWrite(ledpin, HIGH);
Serial.begin(9600); Serial.begin(9600);
} }
//funcs:
void fmtky() {}
void fmlol() {}
void fmnws() {}
void fmfky() {}
void fmshl() {}
void fmshg() {}
void fmgdr() {}
void fmezg() {}
void fmsbr() {}
void fmszr() {}
void fmclb() {}
void fmglp() {}
void fmcbh() {}
void fmcbv() {}
void fmcbs() {}
void fmexr() {}
void loop() void loop()
{ {
char key = kpd.getKey(); char key = kpd.getKey();
if(key) // Check for a valid key. if(key) {
{ switch (key) {
switch (key) case '0':
{ fmtky();
case '*':
digitalWrite(ledpin, LOW);
break; break;
case '#': case '1':
digitalWrite(ledpin, HIGH); fmlol();
break; break;
default: case '2':
Serial.println(key); fmnws();
break;
case '3':
fmfky();
break;
case '4':
fmshl();
break;
case '5':
fmshg();
break;
case '6':
fmgdr();
break;
case '7':
fmezg();
break;
case '8':
fmsbr();
break;
case '9':
fmszr();
break;
case 'a':
fmclb();
break;
case 'b':
fmglp();
break;
case 'c':
fmcbh();
break;
case 'd':
fmcbv();
break;
case 'e':
fmcbs();
break;
case 'f':
fmexr();
break;
default:
Serial.println(key);
} }
delay(100);
} }
} }