2.1.9: Sweeping Servo 11/21
- Due Nov 21, 2022 by 11:59pm
- Points 100
- Submitting a text entry box
Write a program that will solve the following task:
- Sweep a servo motor through all possible values
- Start a servo motor at position 0
- Slowly increase the position of the servo (increasing the position by 1 degree every 10ms is a good speed) until it reaches a position of 180 degrees
- Then decrease the position of the servo back to 0 in the same way
- Repeat this motion until the program is manually ended.
- Use the following diagram to connect the servo to your Arduino
To Develop your program:
- Build your circuit simulation in Tinkercad.
- Type the following into the code section of Tinkercad to get started:
// Add Servo library & create a servo called myServo in Pin 5
#include <Servo.h>
Servo myServo;
void setup(){
myServo.attach(5);
myServo.write(0);
}
void loop(){
}
- Write your code inside the loop function using the commands you’ve learned. (Don’t forget comments!)
- Run your program on the simulation and on your physical device.
- Once you are sure that you’ve solved each portion of the problem, copy and paste your code from the Tinkercad editor into here to save it.
- Click the ‘Submit’ button to submit your program to your teacher for grading.
Example: