Arduino: Rotary Encoder
Revision as of 07:33, 6 October 2016 by Onnowpurbo (talk | contribs) (Created page with " #include <rotary.h> Rotary r = Rotary(2, 3); void setup() { Serial.begin(9600); PCICR |= (1 << PCIE2); PCMSK2 |= (1 << PCINT18) | (1 << PCINT19); sei();...")
#include <rotary.h> Rotary r = Rotary(2, 3); void setup() { Serial.begin(9600); PCICR |= (1 << PCIE2); PCMSK2 |= (1 << PCINT18) | (1 << PCINT19); sei(); } void loop() { } ISR(PCINT2_vect) { unsigned char result = r.process(); if (result) { Serial.println(result == DIR_CW ? "Right" : "Left"); } }