Arduino encoder library
Encoder library is published by pjrc
The code
#include "Encoder.h" Encoder encoder(2, 4); void setup() { attachInterrupt(0, doEncoder, CHANGE); Serial.begin (115200); Serial.println("start"); } void loop(){ // do some stuff here - the joy of interrupts is that they take care of themselves } void doEncoder(){ encoder.update(); Serial.println( encoder.getPosition() ); }
Related posts:
- MQTT on Arduino Mega 2560 and enc28j60 network module Cabling ENC CS -> Arduino SS (pin 53) ENC SI -> Arduino MOSI (pin 51) ENC SO -> Arduino MISO (pin 50) ENC SCK -> Arduino SCK (pin 52) ENC...
- Reading Rotary Encoder The XOR logical table can help with reading and computing rotary encoder output. Rotary encoder has 2 outputs, that returns a state, using “grey” code. When encoder turns un Clockwise(CW),...
- Test driven programming Test driven programming is a base of Extreme Programming. But this could be a good practice for any method… What is test driven programming ? A strict methodology shall be...
- BCD/decimal conversion As Flight Simulator published radio freqencies in BCD, it is necessary to convert them before computing frequency change. Note: frequencies are not fully published in BCD. For example, for COM...
- Access Variables/Property tree in FS,FlightGear and XPlane How to talk with your simulator ? Add-ons developper or cockpit builders have to access flight simulator variables, to mange or display them. If coding is not your cup of...