May 27, 2012 at 4:45 pm #7919
Interesting project. I think you should continuosly check and compare the value from the adc with your reference value.
Are you using timers for generating PWM or simply delay waiting inside a continuous loop?
Anyway, there should be a condition check for same adc value and reference value. If the condition fails, you should update the number of counts required in timer ISR or the delay required in the code (increase or decerease depending whether the adc value is lesser or greater than the reference).
Hope you got some idea.