I used one of these following the bildr tutorial on an arduino and it worked fine, but when I tried to use it on an ATtiny, I ran into problems. Turning the knob didn’t adjust the value at all, though at least there was no change when I wasn’t moving it. I can’t for the life of me figure out why. The ATtiny is operating at slightly slower speed (8MHz as opposed to 16MHz) but should be more than enough when all it’s doing is checking an encoder. The first thing I suspected was that the Software Serial was causing problems. So I took it out and used an led to represent the turning. Still didn’t fix it. I originally had the software serial tx pin as digital pin 2 on the ATtiny (using pins 0,1 for encoder). I thought maybe this was causing problems so I moved it to pin 4. It started to work better but not near as well as when it was on the arduino. It moved very very slowly when I turned the knob; maybe +– four values for a full rotation. The next thing I tried was changing the bildr code since it declared variables every time it went through the ISR (Interrupt Service Routine) loop. I moved the declarations outside the loop but that didn’t help anything. The final thing I did was to get rid of the interrupts and just have it check the status of the encoder pins every time it went through the loop. After this it worked perfectly, even when I moved the Software Serial back to pin 2. So I still don’t know what the problem was, but I know it works this way. The only real downside for me is that you can’t use any kind of delay in the loop because it may miss part of the encoder turn. If anybody can tell me what my problem was or has had similar experiences, please leave me a comment. You can view a more detailed description here: http://thewanderingengineer.com/2013/05/05/rotary-encoder-with-the-attiny85/
↧