Question: please give a C++ code for the following question. This experiment will require the use of a single pushbutton and the serial monitor on the
please give a C++ code for the following question.
This experiment will require the use of a single pushbutton and the serial monitor on the computer in addition to the servo motor. Construct the circuit and program to do the following:
1. When the pushbutton (PB) is initially pressed, the servo should automatically go to the center of its motion, and the serial monitor should display System active.
2. After the system is activated, the serial monitor should prompt the user to input an angle from 0 to 180 degrees. If a correct angle is entered, the servo should rotate to that angular position. Once the angular position is reached, the servo should hold at that position, and the serial monitor screen should prompt the user for a new angle. This procedure should be repeated as long as the system is active.
3. If an angle is entered outside of the indicated range, and error message should appear and the user should be prompted to enter a new angle.
4. Pressing PB a second time turns the system off. The servo should move to the home position, and the message System deactivated should appear.
5. While system is deactivated, it should be waiting for the user to activate it again.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
