Develop the program to control the operation of a servo motor. Consider that the motor is controlled with the contact 9 of the ARDUINO platform, that two pushbuttons P1 and P2 have been adapted to the contacts 2 and 3 of the ARDUINO.
P1 will have the function of activating or stopping the motor and P2 will have the function of changing the positioning angle.
The servo motor will start at 90 ° and even though the pushbutton P2 can be activated, the servo motor will remain at 90 °, since it is in the off state.
In order for the motor to be able to change its angle depending on whether the pushbutton P2 is activated, the pushbutton P1 must be activated once. From this moment the servo is in the on state and can already be positioned as ordered by the pushbutton P2.
The first time the pushbutton P2 is activated, the servo will rotate to 120 ° and will stop there. If the P2 button is activated again, the servo will rotate to 60 ° and will stop there. If the pushbutton P2 is activated again, the servo again will rotate up to 120 °, and so on. Positioning changes must be continuous (from grade to grade) using a delay of 5ms per degree.
If the pushbutton P1 is activated again the servo motor will go to the off state and therefore the pushbutton P2 will be activated, the servo will no longer move. In order for the servo to rotate again according to P2 activations, it is necessary to activate the pushbutton P1 again.