arduino-joystick/example/obsolete/basic/basic.ino

35 lines
1.1 KiB
C++

// An example sketch using the joystick library.
// In this example, we have 3 toggle switches and 2 momentary pushbuttons.
// Each button is configured in a different one of the available behaviors.
#include <Joystick.h>
bool debug = false;
Joystick joystick(debug);
void setup() {
// momentary pushbutton #1
joystick.AddButton(9, BUTTON_PASSTHRU);
// momentary pushbutton #2 - this one will toggle on or off each time it is pushed
joystick.AddButton(10, BUTTON_LATCHED_MOMENTARY);
// a toggle switch that acts like a momentary button - every time it's toggled 'on' it briefly sends
// a keypresss
joystick.AddButton(11, BUTTON_PULSED);
// like the above, but it sends its button press when toggled on *and* when toggled off
joystick.AddButton(12, BUTTON_PULSED_DOUBLE_ACTION);
// again, similar to the above, but it sends two *different* button presses - 'on' will be one button, 'off' another.
joystick.AddButton(13, BUTTON_PULSED_DOUBLE_ACTION_SPLIT);
// start up serial communication
joystick.Init();
}
void loop() {
// check all the button states and send any changes
joystick.Update();
}