Clean up examples directory.
This commit is contained in:
parent
d6e0648abf
commit
5c2a2736dc
7 changed files with 70 additions and 1 deletions
34
examples/basic/basic.ino
Normal file
34
examples/basic/basic.ino
Normal file
|
@ -0,0 +1,34 @@
|
|||
// 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();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue