Skip to content

Instantly share code, notes, and snippets.

@taybenlor
Created February 23, 2020 08:04
Show Gist options
  • Save taybenlor/1fa3bf355481e6d9ca555240aacc01c6 to your computer and use it in GitHub Desktop.
Save taybenlor/1fa3bf355481e6d9ca555240aacc01c6 to your computer and use it in GitHub Desktop.
#include <Mouse.h>
#define enc_dt 2
#define enc_clk 3
int responseDelay = 2; // response delay of the mouse, in ms
void setup() {
Mouse.begin();
pinMode(enc_dt, INPUT_PULLUP);
pinMode(enc_clk, INPUT_PULLUP);
pinMode(button, INPUT);
attachInterrupt(digitalPinToInterrupt(enc_clk), onTurn, FALLING);
}
void loop() {
}
void onTurn() {
if (digitalRead(enc_clk) == digitalRead(enc_dt)) {
Mouse.move(0, 0, -1); // Scroll mouse up (I think, its one of those)
} else {
Mouse.move(0, 0, 1); // Scroll mouse down (the other direction)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment