Add an equivalent example using the new Joystick API. Also add pin initializing code to Joystick::AddButton()
This commit is contained in:
@ -2,6 +2,9 @@
|
||||
// In this example, we have 5 toggle switches that are configured
|
||||
// as double-action pulsed buttons - that is, whenever they are toggled, they
|
||||
// emit a short button press.
|
||||
//
|
||||
// This example uses the *old* Joystick API. You should strongly prefer the
|
||||
// other, better examples in this directory!
|
||||
|
||||
#include <Joystick.h>
|
||||
|
||||
|
22
examples/switch_panel_improved.ino
Normal file
22
examples/switch_panel_improved.ino
Normal file
@ -0,0 +1,22 @@
|
||||
// This is the same 5-toggle-switch example from switch_panel.ino, using the
|
||||
// new API. So much easier!
|
||||
|
||||
#include <Joystick.h>
|
||||
|
||||
Joystick joystick;
|
||||
|
||||
void setup() {
|
||||
pinMode(13, OUTPUT);
|
||||
digitalWrite(13, LOW);
|
||||
|
||||
joystick.Init();
|
||||
joystick.AddButton(2, BUTTON_PULSED_DOUBLE_ACTION, true);
|
||||
joystick.AddButton(3, BUTTON_PULSED_DOUBLE_ACTION, true);
|
||||
joystick.AddButton(4, BUTTON_PULSED_DOUBLE_ACTION, true);
|
||||
joystick.AddButton(5, BUTTON_PULSED_DOUBLE_ACTION, true);
|
||||
joystick.AddButton(6, BUTTON_PULSED_DOUBLE_ACTION, true);
|
||||
}
|
||||
|
||||
void loop () {
|
||||
joystick.Update();
|
||||
}
|
Reference in New Issue
Block a user