Created
January 28, 2019 10:47
-
-
Save darksidelemm/427bfeb35db978dd3152af3158185242 to your computer and use it in GitHub Desktop.
BigScroll.ino
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Mouse.h" | |
#include <Encoder.h> | |
// Change these two numbers to the pins connected to your encoder. | |
// Best Performance: both pins have interrupt capability | |
// Good Performance: only the first pin has interrupt capability | |
// Low Performance: neither pin has interrupt capability | |
Encoder myEnc(2, 3); | |
// avoid using pins with LEDs attached | |
void scrollUp() { | |
Mouse.move(0,0,-1); | |
} | |
void scrollDown() { | |
Mouse.move(0,0,1); | |
} | |
void setup() { | |
Mouse.begin(); | |
} | |
long oldPosition = -999; | |
void loop() { | |
long newPosition = myEnc.read(); | |
if (newPosition != oldPosition) { | |
if(newPosition>oldPosition){ | |
scrollUp(); | |
}else if(newPosition<oldPosition){ | |
scrollDown(); | |
} | |
oldPosition = newPosition; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment