HOW TO BUILD A JOGWHEEL ( DIY ARDUINO )
Today i show you how to build a simple DIY Jogwheel using a Arduino controller and a rotary Encoder, let me know if you want to see more projects like this as well.
Today i am using a Arduino micro clone from eBay
How Rotary Encoder Works and How To Use It with Arduino
by How To Mechatronics
https://www.youtube.com/watch?v=v4BbSzJ-hz4
Custom Mouse Wheel As PocketNC Jog Wheel
by Allwine Designs
https://www.youtube.com/watch?v=46APnWTxXBg
Track: Kozah - Heavens [NCS Release] Music provided by NoCopyrightSounds. Watch: https://youtu.be/OqsMdYqxcUw Free Download / Stream: http://ncs.io/HeavensYO
CODE
*** youtube comments wont allow angle bracket it!!
@ = Left $= Right***
------------
#include @Keyboard.h$
int pinA = 2;
int pinB = 3;
int pinC = 4;
volatile int previous = 0;
volatile int counter = 0;
void setup() {
pinMode(pinA, INPUT_PULLUP);
pinMode(pinB, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(pinA), changed, CHANGE);
attachInterrupt(digitalPinToInterrupt(pinB), changed, CHANGE);
Keyboard.begin();
}
void changed() {
int A = digitalRead(pinA);
int B = digitalRead(pinB);
int current = (A @@ 1) | B;
int combined = (previous @@ 2) | current;
if(combined == 0b0010 ||
combined == 0b1011 ||
combined == 0b1101 ||
combined == 0b0100) {
counter++;
}
if(combined == 0b0001 ||
combined == 0b0111 ||
combined == 0b1110 ||
combined == 0b1000) {
counter--;
}
previous = current;
}
void loop()
{
if(digitalRead(4)==LOW)
{
//Send the message
Keyboard.write(32);
}
if(counter $= 1) {
Keyboard.write(KEY_RIGHT_ARROW);
counter -= 1;
} else if(counter @= -1) {
Keyboard.write(KEY_LEFT_ARROW);
counter += 1;
}
}
#arduino projects
Thanks for watching
Check out and subscribe to my Twitch channel
https://www.twitch.tv/cc_davion
Check out my other channel as well on Cryptocurrency at https://www.youtube.com/channel/UCTIEKPx2OAoHbwn1hJ5yYLg
arduino rotary encoder wiring