Announcement

Collapse
No announcement yet.

Optishot Remote for < $20

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Optishot Remote for < $20

    Build a wooden box with some buttons, a joystick and a Arduino board.

    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



    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
    }

  • #2
    Eezetee thats fantastic! I have been looking for something like this for a DIY project. One question though, is there a max of 7 buttons allowed, in relation to the 7 PWM pins? Or could you program more?

    Comment


    • #3
      Originally posted by nezzie View Post
      Eezetee thats fantastic! I have been looking for something like this for a DIY project. One question though, is there a max of 7 buttons allowed, in relation to the 7 PWM pins? Or could you program more?
      Glad I could I could give back to the forum that helped me.

      No, 7 is not the limit. I have 11 buttons, including the 4 buttons for the joystick. There are 13 inputs on the Leonardo. Some of the other arduino's would work but you should make sure they have HID.

      My setup is in the attached. Those were the most. I was thinking to add a volume up and volume down on the PC as I often play music too.

      I'm wondering if maybe I should make a video for how to program a board or wire up these? I don't care to make money off of it, just wanted to give back.

      Comment


      • #4
        Are you still thinking about doing a video? I would love to see that.

        Comment


        • #5
          Do you need help with Arduino programming or the actual wiring? I'm willing to help but just don't want to burn time on areas not needed.

          Comment


          • #6
            I haven't given it a lot of thought yet. You had mentioned possibly doing a video. If/when I decided to make one I'll pick your brain if I get stuck.

            Comment


            • #7
              Here are a few videos of how to get started and wiring.

              Have a look at those and we can adapt to suit this project.

              Code above is basically done. Do you know what to order?

              Arduino - http://forefront.io/a/beginners-guide-to-arduino/
              Wiring here - http://www.koenigs.dk/mame/eng/basicwiringguide.htm

              Comment


              • #8
                Really cool to use the arduino for this!

                I've been playing around with a few ideas for button controls and bought one of the $20 zero delay usb controllers with the buttons and joystick. I haven't made a box yet. Have you ever done anything with those?

                Also, I picked up one of those $40 fighting boxes and have mapped the buttons and stick to TGC commands - works great, but hardly as cool or rewarding.

                Click image for larger version

Name:	Screenshot (95).png
Views:	3366
Size:	112.1 KB
ID:	107313

                Comment


                • eezetee
                  eezetee commented
                  Editing a comment
                  Haven't toyed around with the zero delay controllers. On that fight stick arcade controller, you could just put some labels on the buttons and be done. Either that or a bluetooth keyboard.
                  I did the optishot box out of necessity as I didn't want to walk over to the computer every time I wanted to preview a hole or change clubs. Your solution also works and would have saved me construction time

              • #9
                I bought the zero delay usb button kit and used joy2key to map all the buttons as well. The problem i'm having is that everything works if i use it in a browser or something but nothing happens when trying to use it with the optishot. It is like the optishot doesn't recognize it. Is there a setting i need to change? Any help would be appreciated.

                Comment


                • eezetee
                  eezetee commented
                  Editing a comment
                  Run both optishot and joy2key not as administrator

                  If that doesn't work. Make sure joy2key is not running, start optishot then try using alt-tab and running joy2key after optishot is running.

                • chevynut
                  chevynut commented
                  Editing a comment
                  I am having the exact same issue as you. Did you ever get this to work properly? I have starting JoytoKey after OptiShot is open, and making sure they are NOT running as Administrator. Any insight would be greatly appreciate. Thanks, Mike

              • #10
                Dmyers - I think there is something related to joy2key that you have to set. Like a global parameter. I have a large arcade cabinet that I use joy2key and some of the emulators didn't work. Can you try something for me?
                Run both optishot and joy2key not as administrator
                If that doesn't work. Make sure joy2key is not running, start optishot then try using alt-tab and running joy2key after optishot is running.
                Let me know how those 2 tests go.

                Awisnia, Haven't toyed around with the zero delay controllers. On that fight stick arcade controller, you could just put some labels on the buttons and be done. Either that or a bluetooth keyboard.
                I did the optishot box out of necessity as I didn't want to walk over to the computer every time I wanted to preview a hole or change clubs. Your solution also works and would have saved me construction time

                Comment


                • #11
                  Originally posted by eezetee View Post

                  Awisnia, Haven't toyed around with the zero delay controllers. On that fight stick arcade controller, you could just put some labels on the buttons and be done. Either that or a bluetooth keyboard.
                  I did the optishot box out of necessity as I didn't want to walk over to the computer every time I wanted to preview a hole or change clubs. Your solution also works and would have saved me construction time
                  eezetee Yeah, but yours is so much cooler and rewarding. Love the golf ball joystick!

                  My 12 year old and I have teamed up making skytrak cases and we're always talking about something that could replace the keyboard. He's got an arduino and pi, but has gotten more into building his gaming pc lately. This will be a great project to bring him back to the 'duino. Thanks for sharing - we'll do the same if/when we do similar for our TGC setup. We're talking about a combination club rack and button bar that we could make out of steel. Everything at your fingertips, so to speak.

                  I was looking over your sketch...had to find the optishot kb shortcuts and do some searching to understand the table of KB modifiers over the ascii table - will help with other projects. Thanks again fro sharing - I learned something.

                  Comment


                  • #12
                    Oh - and there's this:

                    http://golfingator.wixsite.com/golfingatoroptishot/optishotremotecontrollerhome

                    Click image for larger version

Name:	golfingator.jpg
Views:	3662
Size:	450.9 KB
ID:	107634

                    Comment


                    • #13
                      Not sure the above and what it's built on. Customizable?

                      Here is the link to the buttons and my setup... The keyboard shortcuts are just a clip from the optishot website.
                      The Ascii codes are in the sketch.


                      Comment


                      • #14
                        I am having the exact same issue as DMeyers from post above. Did you ever get this to work properly? I have starting JoytoKey after OptiShot is open, and making sure they are NOT running as Administrator. Any insight would be greatly appreciate. Thanks, Mike

                        Comment


                        • #15
                          I have it working now. I am not sure what I did besides running JoytoKey as an admin?

                          Comment

                          Working...
                          X