Skip to content

Instantly share code, notes, and snippets.

@houmei
Created May 7, 2016 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save houmei/3625551d7013cbd2bff2159a96ebc4b3 to your computer and use it in GitHub Desktop.
Save houmei/3625551d7013cbd2bff2159a96ebc4b3 to your computer and use it in GitHub Desktop.
RotaryEncoder(Analog input)
const int analogInPin = A0; // Analog input pin that the potentiometer is attached to
int sensorValue = 0; // value read from the pot
int o,oo;
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
o = (sensorValue)>>6;
if ( o!=oo ) {
Serial.println(o);
oo=o;
}
// delay(2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment