This circuit is designed to control a servo motor using an Arduino UNO microcontroller. The servo is powered by a voltage regulated supply, which is connected to a 2.1mm Barrel Jack with Terminal Block. The voltage regulator ensures that the servo receives a stable voltage, while the capacitors are used to filter the power supply to prevent any voltage spikes or noise. The servo is controlled by the Arduino UNO through one of its digital pins, which sends pulse-width modulation (PWM) signals to the servo to control its position.
The following code is written for the Arduino UNO microcontroller to control the servo motor:
/**
* This example demonstrates how to control a continuous rotation servo motor.
* In this example, the servo spins forward for 1 second, pauses for 1 second,
* spins backwards for 1 second, and pauses for 1 second in a loop.
*
* This example was written by Cirkit Design LLC.
*/
#include <Servo.h>
Servo myservo;
int pos = 0;
void setup() {
// The servo control wire is connected to Arduino D2 pin.
myservo.attach(2);
// Servo is stationary.
myservo.write(90);
}
void loop() {
// Servo spins forward at full speed for 1 second.
myservo.write(180);
delay(1000);
// Servo is stationary for 1 second.
myservo.write(90);
delay(1000);
// Servo spins in reverse at full speed for 1 second.
myservo.write(0);
delay(1000);
// Servo is stationary for 1 second.
myservo.write(90);
delay(1000);
}
This code is saved in a file named sketch.ino
. The code sets up the servo on digital pin 2 and controls its movement in a loop, alternating between spinning forward, pausing, spinning in reverse, and pausing.