Reading Encoders with Arduino
We will be updating this page for our new encoders that have only one output.
When an encoder is spinning full speed, it can be outputting more than 3000ticks/second. In order to count all of these ticks, we will need a very fast code that runs in the "background" of our main code. Unfortunately, Arduino does not offer real time processing or parallel threads, so the next closest thing are interrupts.
Arduino UNO has two external interrupt pins: Digital pin 2 and 3. By using the attachInterrupt function, you use an external signal attached to pin 2 and 3 to interrupt your code. For more details, see: attachInterrupt
Encoder Test Code:
Wiring Instructions (pololu motor):
copy and paste code into a new sketch: