Created
February 23, 2020 08:04
-
-
Save taybenlor/1fa3bf355481e6d9ca555240aacc01c6 to your computer and use it in GitHub Desktop.
This file contains 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> | |
#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