Hi guys,
i'm trying to build up a button box for my simulator and ran across a major problem (at least for my skill set). Here is what i want to do:
Have 3 Buttons which act like this-> pressing will give a signal (button push), releasing the same button will also give the same or a different button push.
Plus having several other buttons acting like normal buttons do (you have to push them to get a signal and that's it).
Preferably it would be nice to use the joystick.h library, since i already have a Arduino as a keyboard (for my other button box).
I already found this example here on the forum, but i'm really struggeling to have more than one key/button and to "translate" it to the joystick library.
Maybe someone would be kind enough to help me out with this.
Thanks in advance for all inputs and help!
#include <Keyboard.h>
const byte switchPin = 8;
byte oldSwitchState = HIGH; // assume switch open because of pull-up resistor
const unsigned long debounceTime = 10; // milliseconds
void setup ()
{
Serial.begin (9600);
pinMode (8, INPUT_PULLUP);
} // end of setup
void loop ()
{
Keyboard.begin();
// see if switch is open or closed
byte switchState = digitalRead (switchPin);
// has it changed since last time?
if (switchState != oldSwitchState)
{
oldSwitchState = switchState; // remember for next time
delay (debounceTime); // debounce
if (switchState == LOW)
{
Keyboard.press('A');
delay(100);
Keyboard.releaseAll();
} // end if switchState is LOW
else
{
Keyboard.press('B');
delay(100);
Keyboard.releaseAll();
} // end if switchState is HIGH
} // end of state change
// other code here ...
}