Code including both knob and button function for servos

Hi,

No idea what you mean by not as expected, but if you mean that three servos do nothing while the forth is sweeping, the reason is that you enter a loop after the buttons is pressed. Your code stays in this loop for the full 2.7 seconds it takes your forth servo to sweep, only then do you exit the for loop and check the analog inputs.

Lots of ways to fix this, for a start, the loop function is already a loop, so you could get rid of the 'for' loop and just set var4 to 0 whenever the button is pressed. Then every time your code runs through the loop function, checking all your inputs and updating all your servos on the way, you can check to see if var4 is less than 180, if so add one and update your servo, if not, just carry on until the nex time the buttons is pressed, setting it back to 0 and so on and on ...

Duane B
rcarduino.blogspot.com