#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); // A B C D // QWE RTY UIO ZXC // ASD FGH JKL VBN //UP ARROW PRESSED if (upStatus!=upStatusPrev && upStatus==LOW) { Keyboard.press('X'); /* W, T, I, X */ upStatusPrev=upStatus; } //UP ARROW RELEASED if (upStatus!=upStatusPrev && upStatus==HIGH) { Keyboard.release('X'); /* W, T, I, X */ upStatusPrev=upStatus; } //LEFT ARROW PRESSED if (leftStatus!=leftStatusPrev && leftStatus==LOW) { Keyboard.press('V'); /* A, F, J, V */ leftStatusPrev=leftStatus; } //LEFT ARROW RELEASED if (leftStatus!=leftStatusPrev && leftStatus==HIGH) { Keyboard.release('V'); /* A, F, J, V */ leftStatusPrev=leftStatus; } //DOWN ARROW PRESSED if (downStatus!=downStatusPrev && downStatus==LOW) { Keyboard.press('B'); /* S, G, K, B */ downStatusPrev=downStatus; } //DOWN ARROW RELEASED if (downStatus!=downStatusPrev && downStatus==HIGH) { Keyboard.release('B'); /* S, G, K, B */ downStatusPrev=downStatus; } //RIGHT ARROW PRESSED if (rightStatus!=rightStatusPrev && rightStatus==LOW) { Keyboard.press('N'); /* D, H, L, N */ rightStatusPrev=rightStatus; } //RIGHT ARROW RELEASED if (rightStatus!=rightStatusPrev && rightStatus==HIGH) { Keyboard.release('N'); /* D, H, L, N */ rightStatusPrev=rightStatus; } // START BUTTON PRESSED if (startStatus!=startStatusPrev && startStatus==LOW) { Keyboard.press('Z'); /* Q, R, U, Z */ startStatusPrev=startStatus; } // START BUTTON RELEASED if (startStatus!=startStatusPrev && startStatus==HIGH) { Keyboard.release('Z'); /* Q, R, U, Z */ startStatusPrev=startStatus; } // SELECT BUTTON PRESSED if (selectStatus!=selectStatusPrev && selectStatus==LOW) { Keyboard.press('C'); /* E, Y, O, C */ selectStatusPrev=selectStatus; } // SELECT BUTTON RELEASED if (selectStatus!=selectStatusPrev && selectStatus==HIGH) { Keyboard.release('C'); /* E, Y, O, C */ selectStatusPrev=rightStatus; } }