Sunday, February 9, 2014

Rotary Encoder Controlling Servo Position, With Last Position Memory

Ok, that was a long title, but what does it mean? I have a ham radio buddy that wants to control a variable capacitor with his Arduino. I'm using a Rotary Encoder (digital) for precision instead of a potentiometer (analog) to control the angle of a Servo. The values are constrained to only legitimate values the servo can use.

This project is based on two of my previous articles:

Fun with Servos

Using a Rotary Encoder with the Arduino

The problem we ran into, was that at power down, a rotary encoder does not retain it's position information, so when you power back up, you start back at zero. I added a few lines that writes the current position to EEPROM every time there is a change, so that on power up, the servo returns to the last known position.

Next modification is to add a LCD display instead of using the serial monitor.

Code -
Related Posts Plugin for WordPress, Blogger...