Moved begin() in JoystickMouseControl example.

This commit is contained in:
Tom Igoe 2012-03-28 14:40:44 -04:00
parent f4746a6b25
commit 57b3395691
1 changed files with 3 additions and 3 deletions

View File

@ -21,7 +21,7 @@
you can turn on and off mouse control.
created 15 Sept 2011
updated 27 Mar 2012
updated 28 Mar 2012
by Tom Igoe
this code is in the public domain
@ -47,6 +47,8 @@ int lastSwitchState = LOW; // previous switch state
void setup() {
pinMode(switchPin, INPUT); // the switch pin
pinMode(ledPin, OUTPUT); // the LED pin
// take control of the mouse:
Mouse.begin();
}
void loop() {
@ -67,8 +69,6 @@ void loop() {
int xReading = readAxis(A0);
int yReading = readAxis(A1);
// take control of the mouse:
Mouse.begin();
// if the mouse control state is active, move the mouse:
if (mouseIsActive) {
Mouse.move(xReading, yReading, 0);