About didgitalpunk

Dec. 1, 2009
I've been bathing in electronics since I was born, and mechanics since my grandpa showed me how his clock worked. As a teenager, I'm a frequent gamer. I like knives because if you know how to wield them properly, they become either a tool, or a most efficient killing machine. And heck! Who doesn't (wouldn't) like snowboarding in the Alps?!
Full Profile »
100+ Comments Earned a bronze medal
  • Improved Arduino Rotary Encoder Reading

    overly complicated...

    The way you do that is you store the last state read from the encoder and compare the current state to the last state. For example: if there is a change from high,high to low,high,  it means you're going in one direction and you can add 1 to your counter or whatever you're using it for. If you go high,high, to low,low , it means you're going the other direction, and you can remove 1 from your counter. bit of code: upState = digitalRead(up);   downState = digitalRead(down);   if(lastDownState == 1 && lastUpState == 1){       if(upState == 0 && downState == 0){       //Detects Counter Clock Wise rotation        timer--;                             // removes 1 from the existing timer count     }}       if(lastDownState == 0 && lastUpState == 0){       if(upState == 1 && downState == 1 ){       //Detects Clock Wise rotation       timer++;                             // adds 1 to the existing timer count     }} upState and downState are my outputs from my encoder, and my encoder track goes like this: _ :low     -  :high track1:  ______----___ track2:  ___---------___ I'm using the same code (adapted a bit of course) on a 2500 step encoder, and it works a charm, even at (fairly) high speeds. -Didgitalpunk

    View Instructable »