#include /* Wood DDR Pad Code * Colbled together by calvinthedestroyer from multiple code examples * date: 1,18,2019 * http://www.DSPrototyping.com */ /* *void setup(): Sets pins 8, 9, 10, 11, 12, 13 to input with internal pull-up resistors enabled and begins Keyboard functionality *void loop(): Main loop - reads pin voltages and sends out corresponding keystrokes via USB */ /* * Pinout: * "HIGH" voltage button contacts - pins 8, 9, 10, 11, 12, 13 * "GND" voltage button contacts - GND pin */ int upStatus=1; int upStatusPrev=1; int leftStatus=1; int leftStatusPrev=1; int downStatus=1; int downStatusPrev=1; int rightStatus=1; int rightStatusPrev=1; int startStatus=1; int startStatusPrev=1; int selectStatus=1; int selectStatusPrev=1; void setup() { /* ply-1 ply-2 ply-3*/ pinMode(8,INPUT_PULLUP); /* 8 UP */ pinMode(9,INPUT_PULLUP); /* 9 DOWN */ pinMode(10,INPUT_PULLUP); /* 10 LEFT */ pinMode(11,INPUT_PULLUP); /* 11 RIGHT */ pinMode(12,INPUT_PULLUP); /* 12 START */ pinMode(13,INPUT_PULLUP); /* 13 SELECT */ Keyboard.begin(); } void loop() { upStatus=digitalRead(8); downStatus=digitalRead(9); rightStatus=digitalRead(10); leftStatus=digitalRead(11); startStatus=digitalRead(12); selectStatus=digitalRead(13); //UP ARROW PRESSED if (upStatus!=upStatusPrev && upStatus==LOW) { Keyboard.press('T'); /* T, I */ upStatusPrev=upStatus; } //UP ARROW RELEASED if (upStatus!=upStatusPrev && upStatus==HIGH) { Keyboard.release('T'); /* T, I */ upStatusPrev=upStatus; } //LEFT ARROW PRESSED if (leftStatus!=leftStatusPrev && leftStatus==LOW) { Keyboard.press('F'); /* F, J */ leftStatusPrev=leftStatus; } //LEFT ARROW RELEASED if (leftStatus!=leftStatusPrev && leftStatus==HIGH) { Keyboard.release('F'); /* F, J */ leftStatusPrev=leftStatus; } //DOWN ARROW PRESSED if (downStatus!=downStatusPrev && downStatus==LOW) { Keyboard.press('G'); /* G, K */ downStatusPrev=downStatus; } //DOWN ARROW RELEASED if (downStatus!=downStatusPrev && downStatus==HIGH) { Keyboard.release('G'); /* G, K */ downStatusPrev=downStatus; } //RIGHT ARROW PRESSED if (rightStatus!=rightStatusPrev && rightStatus==LOW) { Keyboard.press('H'); /* H, L */ rightStatusPrev=rightStatus; } //RIGHT ARROW RELEASED if (rightStatus!=rightStatusPrev && rightStatus==HIGH) { Keyboard.release('H'); /* H, L */ rightStatusPrev=rightStatus; } // START BUTTON PRESSED if (startStatus!=startStatusPrev && startStatus==LOW) { Keyboard.press('R'); /* R, U */ startStatusPrev=startStatus; } // START BUTTON RELEASED if (startStatus!=startStatusPrev && startStatus==HIGH) { Keyboard.release('R'); /* R, U */ startStatusPrev=startStatus; } // SELECT BUTTON PRESSED if (selectStatus!=selectStatusPrev && selectStatus==LOW) { Keyboard.press('Y'); /* Y, O */ selectStatusPrev=selectStatus; } // SELECT BUTTON RELEASED if (selectStatus!=selectStatusPrev && selectStatus==HIGH) { Keyboard.release('Y'); /* Y, O */ selectStatusPrev=rightStatus; } }