Big Red Button Macro

Discussion in 'Electronics & Electrics' started by riccoo, Jun 13, 2019.

  1. riccoo

    riccoo Member

    Joined:
    Jan 15, 2014
    Messages:
    951
    Location:
    Sydney
    Hey all i need to make a Big Red Button run a macro that says ALT + F9 on my pc, i can find the big red buttons but no idea how to get it to talk to my pc anyone able to help me :)

    Big red Button
     
  2. _zak

    _zak Member

    Joined:
    Oct 12, 2009
    Messages:
    341
    Easiest way to do this would be with an Pro Micro and the Arduino IDE. The 32u4 chip in there can be programmed to behave like an HID device (i.e. keyboard/mouse), and the code would be pretty simple.

    One side of the button switch should be connected to ground, and the other should be connected to one of the Pro Micro pins (in the example below, pin 9). The code would look something like this (mostly taken from this SparkFun tutorial):

    Code:
    int buttonPin = 9;  // Digital pin the button is connected to
    
    void setup()
    {
      pinMode(buttonPin, INPUT);  // Set the button as an input
      digitalWrite(buttonPin, HIGH);  // Pull the button high
    }
    
    void loop()
    {
      if (digitalRead(buttonPin) == 0)  // if the button goes low
      {
        Keyboard.press(KEY_LEFT_ALT);  // press the ALT key
        Keyboard.write(KEY_F4); // then the F9 key
        Keyboard.release(KEY_LEFT_ALT); // now release the F9 key
        delay(1000);  // delay for cheap debouncing
      }
    }
     
  3. OP
    OP
    riccoo

    riccoo Member

    Joined:
    Jan 15, 2014
    Messages:
    951
    Location:
    Sydney
    would any of these do it XC4414 or XC9046
     
  4. OP
    OP
    riccoo

    riccoo Member

    Joined:
    Jan 15, 2014
    Messages:
    951
    Location:
    Sydney
  5. _zak

    _zak Member

    Joined:
    Oct 12, 2009
    Messages:
    341
    The first Arduino clone uses the ATMega328p chip, which can't be set up to behave as a keyboard (at least not easily). The second one looks fairly ideal for your situation - you'd just need a program to intercept the joystick commands and send the one you want instead.

    The Digispark is a great little board, and has a keyboard library (you can see an example of using it for a macro keyboard here). USB is implemented through a bit of a hack though, so they can be a bit quirky and might not be the best choice if this is your first time working with Arduino/hardware.
     
  6. pantner

    pantner Member

    Joined:
    Aug 31, 2004
    Messages:
    2,224
    Location:
    Perth, WA
    I like the look of this better.

    https://timmyomahony.com/blog/making-usb-push-buttons/

    for one it makes use of the pullup resistor.

    That also using a debounce library.
    When you push a push button, sometimes it can trigger multiple times (especially when using cheap buttons) as the contacts "bounce".
     
  7. v81

    v81 Member

    Joined:
    Jan 31, 2005
    Messages:
    662
    Location:
    SE Vic
    As an alternative there is a project called MMjoy that turns an ATmega32u4 based Arduino or Teensy into a HID input.
    Bonus here is that the config is all done in a GUI.
    The process for writing the bootloader needs to be done with care as most people struggle with it, but after that you're all set.
    Lots of info in this forum post over at SimHQ

    Highly recommended for anyone wanting to build joysticks or or button panels.
     

Share This Page

Advertisement: