For school I have to make a program with 2 servos, a potentiometer and a push button. When I use the potentiometer the servos have to turn a certain amount of degrees. And when I press the push button the 2 servos have to turn 90 °. Everything works, but when I add the push button to the program, the servos start to shake a lot. I included the arduino file and a .png of the program.
Your code will move the servo to 0 or 90 degrees depending on if the button is pressed or not. BUT it will also change the position of the servo depending on the pot value.
Can you see why this is silly? The servo dosn't know what to do because it is ALWAYS being told to go to two different places within microseconds of each other.
Yes, I see whats wrong but I do not know how I can fix this problem ? I am kinda new to programming with arduino. But thank you for responding already.
Sorry, I will not do your homework for you. But you already have an if statement, that defines what the servo does when the button is pressed. Have a look at that and think what you could change so that the servo moves according to the potentiometer if the button is not pressed. Then show us what you changed and describe what is going wrong if it does not work as expected.