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

35 lines
1.1 KiB
Arduino
Raw Normal View History

// 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() {
2021-11-02 19:55:35 +00:00
// momentary pushbutton #1
joystick.AddButton(9, BUTTON_PASSTHRU);
2021-11-02 19:55:35 +00:00
// momentary pushbutton #2 - this one will toggle on or off each time it is pushed
joystick.AddButton(10, BUTTON_LATCHED_MOMENTARY);
2021-11-02 19:55:35 +00:00
// 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);
2021-11-02 19:55:35 +00:00
// like the above, but it sends its button press when toggled on *and* when toggled off
joystick.AddButton(12, BUTTON_PULSED_DOUBLE_ACTION);
2021-11-02 19:55:35 +00:00
// 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);
2021-11-02 19:55:35 +00:00
// start up serial communication
joystick.Init();
}
void loop() {
2021-11-02 19:55:35 +00:00
// check all the button states and send any changes
joystick.Update();
}