I've gotten a lot of help from here so figured i'd share back. Not sure if this was the place to post but I'm planning to make a pocket remote for controller my simulator. First step was to make a box with buttons and try it. Waiting for my office to be build and starting toying around. Just need to change the buttons for any system.
Wood box which is 30cm by 30cm. The button holes are 29mm and the joystick was 35mm. All of these parts cant be bought on many websites. Just search arcade parts. The other item was a Leonardo Arduino compatibile board because it has a UART chip / HID that can do USB to the PC.
So, in summary
7 HAPP style buttoms
1 Joystick - I cut the head off and mount a golf ball on it for effect
1 - Ground cable that connects all of the switches (on the joystick too)
11 - Single headed cables to connect to the Leoardo
1 - Leonardo . Prices as low as $10 - https://www.arduino.cc/en/Main/ArduinoBoardLeonardo
So all in money output was about $17. Time to make the box was 2 hours because i'm not proficient in that. Coding time for the board was about 30 minutes.
Figured I'd share with everyone else here.
Attached is pictures
Here is the video - https://youtu.be/v7F9R-KMOTQ
Attached is the Arduino code - as zip file, rename to INO as Arduino code- Also below just in case
Wood box which is 30cm by 30cm. The button holes are 29mm and the joystick was 35mm. All of these parts cant be bought on many websites. Just search arcade parts. The other item was a Leonardo Arduino compatibile board because it has a UART chip / HID that can do USB to the PC.
So, in summary
7 HAPP style buttoms
1 Joystick - I cut the head off and mount a golf ball on it for effect
1 - Ground cable that connects all of the switches (on the joystick too)
11 - Single headed cables to connect to the Leoardo
1 - Leonardo . Prices as low as $10 - https://www.arduino.cc/en/Main/ArduinoBoardLeonardo
So all in money output was about $17. Time to make the box was 2 hours because i'm not proficient in that. Coding time for the board was about 30 minutes.
Figured I'd share with everyone else here.
Attached is pictures
Here is the video - https://youtu.be/v7F9R-KMOTQ
Attached is the Arduino code - as zip file, rename to INO as Arduino code- Also below just in case
Code:
#include <Keyboard.h>
// char ctrlKey = KEY_LEFT_CTRL;
char ctrlKey = KEY_LEFT_GUI;
bool pressed = false;
void setup() {
// V0 T.S - Intial Sketch Idea
// V0.1 T.S. -- Pulled in Decimal Values from here http://www.asciitable.com/
// V0.2 - Change the pinmode and buttonState to arrays after troubleshooting.
// V0.3 - Wiring Test
// V0.4 - Button Programming - Reference for Control+Key - https://www.arduino.cc/en/Reference/KeyboardPress
// V0.5 - Fixed some repeat characters due to timing - delay of 250 is the lowest without guaranteed repeats
Keyboard.begin();
//Joystick and button connections
pinMode(1, INPUT_PULLUP); //Button 1
pinMode(2, INPUT_PULLUP); //Button 2
pinMode(3, INPUT_PULLUP); //Button 3
pinMode(4, INPUT_PULLUP); //Button 4
pinMode(5, INPUT_PULLUP); //Button 5
pinMode(6, INPUT_PULLUP); //Button 6
pinMode(7, INPUT_PULLUP); //Button 7
pinMode(8, INPUT_PULLUP); //Button 8
pinMode(9, INPUT_PULLUP); //Button 9
pinMode(10, INPUT_PULLUP); //Button 10
pinMode(11, INPUT_PULLUP); //Button 11
pinMode(12, INPUT_PULLUP); //Button 12
pinMode(13, INPUT_PULLUP); //Button 13
}
void loop() {
// Check the switches:
int buttonState1 = digitalRead(1);
int buttonState2 = digitalRead(2);
int buttonState3 = digitalRead(3);
int buttonState4 = digitalRead(4);
int buttonState5 = digitalRead(5);
int buttonState6 = digitalRead(6);
int buttonState7 = digitalRead(7);
int buttonState8 = digitalRead(8);
int buttonState9 = digitalRead(9);
int buttonState10 = digitalRead(10);
int buttonState11 = digitalRead(11);
int buttonState12 = digitalRead(12);
int buttonState13 = digitalRead(13);
//
// we'll only act on a button press if button is low and pressed is false
//
// Button 1, Bottom Right Dark Blue Stripe = Pressed
if (!pressed && buttonState1 == LOW) {
pressed = true;
Keyboard.press(128);
delay(100);
Keyboard.press(217);
delay(100);
Keyboard.releaseAll();
delay(250);
}
else{
pressed = false;
Keyboard.releaseAll();
}
// Button 2, Bottom Right Grey Stripe = Pressed
if (!pressed && buttonState2 == LOW) {
pressed = true;
Keyboard.press(128);
delay(100);
Keyboard.press(218);
delay(100);
Keyboard.releaseAll();
}
else{
pressed = false;
Keyboard.releaseAll();
}
// Button 3 White = Pressed
if (!pressed && buttonState3 == LOW) {
pressed = true;
Keyboard.press(77);
delay(250);
}
else{
pressed = false;
Keyboard.release(77);
}
// Button 4 Light Brown Stripe = Pressed
if (!pressed && buttonState4 == LOW) {
pressed = true;
Keyboard.press(202);
delay(250);
}
else{
pressed = false;
Keyboard.release(202);
}
// Button 5 Black Stripe = Pressed
if (!pressed && buttonState5 == LOW) {
pressed = true;
Keyboard.press(177);
delay(250);
}
else{
pressed = false;
Keyboard.release(177);
}
// Button 6 - Bottom Left - Magenta = Pressed
if (!pressed && buttonState6 == LOW) {
pressed = true;
Keyboard.press(70);
delay(250);
}
else{
pressed = false;
Keyboard.release(70);
}
// Button 7 - Bottom Left - Red = Pressed
if (!pressed && buttonState7 == LOW) {
pressed = true;
Keyboard.press(82);
delay(250);
}
else{
pressed = false;
Keyboard.release(82);
}
// Button 8 - White Joystick Left = Pressed
if (!pressed && buttonState8 == LOW) {
pressed = true;
Keyboard.press(216);
delay(250);
}
else{
pressed = false;
Keyboard.release(216);
}
// Button 9 - Joystick Right = Pressed
if (!pressed && buttonState9 == LOW) {
pressed = true;
Keyboard.press(215);
delay(250);
}
else{
pressed = false;
Keyboard.release(215);
}
// Button 10 - Joystick Up = Pressed
if (!pressed && buttonState10 == LOW) {
pressed = true;
Keyboard.press(218);
delay(250);
}
else{
pressed = false;
Keyboard.release(218);
}
// Button 11 - Joystick Down = Pressed
if (!pressed && buttonState11 == LOW) {
pressed = true;
Keyboard.press(217);
delay(250);
}
else{
pressed = false;
Keyboard.release(217);
}
// End of Sketch here
}

Comment