Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Keyboard.h>
- #include <Keypad.h>
- const byte ROWS = 4; //four rows
- const byte COLS = 4; //three columns
- char keys[ROWS][COLS] = {
- {'1','2','3','A'},
- {'4','5','6','B'},
- {'7','8','9','C'},
- {'*','0','#','D'}
- };
- byte rowPins[ROWS] = {13,12,11,10}; //connect to the row pinouts of the keypad
- byte colPins[COLS] = {9, 8, 7, 6}; //connect to the column pinouts of the keypad
- Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
- bool lightsOn = false;
- void setup(){
- Serial.begin(9600);
- Keyboard.begin();
- }
- void loop(){
- char key = keypad.getKey();
- if (key != NO_KEY){
- if (key == 'A') {
- if (lightsOn) {
- lightsOn = false;
- Keyboard.print('J');
- } else {
- lightsOn = true;
- Keyboard.print('J');
- delay(200);
- Keyboard.print('J');
- delay(200);
- Keyboard.print('J');
- delay(200);
- Keyboard.print('K');
- delay(200);
- Keyboard.print('L');
- }
- } else if (key == 'B') {
- Keyboard.press('G');
- delay(200);
- Keyboard.release('G');
- } else if (key == 'C') {
- Keyboard.print('K');
- } else if (key == 'D') {
- Keyboard.print('L');
- } else if (key == '*') {
- lightsOn = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement