Skip to content

Instantly share code, notes, and snippets.

@darksidelemm
Created January 28, 2019 10:47
Show Gist options
  • Save darksidelemm/427bfeb35db978dd3152af3158185242 to your computer and use it in GitHub Desktop.
Save darksidelemm/427bfeb35db978dd3152af3158185242 to your computer and use it in GitHub Desktop.
BigScroll.ino
#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