Devices & Components
Arduino Leonardo with Headers
Jumper wires (generic)
M3 Heated Inserts
3D filament PLA Black
M3x6 Screws
circuit board
Resistor 10 kΩ
M3x10 Screws
push buttons
Hardware & Tools
3D printer filament (PLA)
Soldering iron (generic)
Software & Tools
Arduino IDE
Project description
Code
Game Controller
cpp
Download the keyboard library.
1# include "Keyboard.h" 2 3int StateOld[7]; 4int StateNew[7]; 5int Pin_Number[7] = {1,2,3,4,5,6,7}; 6int Key_to_Press[7] = {KEY_LEFT_ARROW, KEY_RIGHT_ARROW, KEY_UP_ARROW, KEY_DOWN_ARROW, 'a', 's','d'}; 7 8void setup(){ 9 int i; 10 Serial.begin(9600); 11 for (i = 0; i < 7; ++i ) { 12 pinMode(Pin_Number[i], INPUT); 13 digitalWrite(Pin_Number[i], LOW); 14 StateOld[i] = digitalRead(Pin_Number[i]); 15 StateNew[i] = digitalRead(Pin_Number[i]); 16 } 17} 18 19void loop() { 20 int i; 21 22 for( i = 0 ; i < 7 ; ++i ) { 23 if (StateOld[i] != StateNew[i]) { 24 StateOld[i] = digitalRead (Pin_Number[i]); 25 if (StateOld[i] == HIGH) { 26 Keyboard.press(Key_to_Press[i]); 27 } 28 else if (StateOld[i] == LOW) { 29 Keyboard.release(Key_to_Press[i]); 30 } 31 } 32 StateNew[i] = digitalRead (Pin_Number[i]); 33 } 34}
Downloadable files
main body
STL-file
main_body.stl
backplate
STL-file
backplate.stl
attachment direction
STL-file
attachment_direct.stl
attachment
STL-file, print 3 of these
attachment.stl
button direction
STL-file
button_direct.stl
button
STL-file, print 3 of these
button.stl
Comments
Only logged in users can leave comments