Circuit Documentation
Summary of the Circuit
This circuit consists of an Arduino UNO microcontroller, a servo motor, and a power supply. The Arduino UNO is programmed to control the servo motor, making it sweep from 0 to 180 degrees and back continuously. The servo motor is powered by a 5V power supply, which also provides power to the Arduino UNO. The ground connections are shared among all components to complete the circuit.
Component List
Arduino UNO
- Description: A microcontroller board based on the ATmega328P.
- Pins Used:
IOREFReset3.3V5VGNDVinA0toA5SCLSDAAREFD13toD0
Servo
- Description: A motor capable of precise position control.
- Pins Used:
gndvccpulse
Power Supply
- Description: Provides a stable 5V power source.
- Pins Used:
+-GND
Wiring Details
Arduino UNO
- 5V connected to the
+pin of the Power Supply andvccpin of the Servo. - GND connected to the
-pin of the Power Supply andgndpin of the Servo. - D3 connected to the
pulsepin of the Servo.
Servo
- gnd connected to the
-pin of the Power Supply andGNDpin of the Arduino UNO. - vcc connected to the
+pin of the Power Supply. - pulse connected to the
D3pin of the Arduino UNO.
Power Supply
- + connected to the
5Vpin of the Arduino UNO andvccpin of the Servo. - - connected to the
GNDpin of the Arduino UNO andgndpin of the Servo.
Documented Code
/*
* This Arduino sketch controls a servo motor connected to pin D3.
* The servo is powered by a 5V power supply and shares a common ground.
* The servo will continuously sweep from 0 to 180 degrees and back.
*/
#include <Servo.h>
Servo myServo; // create servo object to control a servo
void setup() {
myServo.attach(3); // attaches the servo on pin D3 to the servo object
}
void loop() {
for (int pos = 0; pos <= 180; pos += 1) { // goes from 0 to 180 degrees
myServo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for (int pos = 180; pos >= 0; pos -= 1) { // goes from 180 to 0 degrees
myServo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}
Filename: sketch.ino
This code is designed to run on an Arduino UNO microcontroller. It initializes a Servo object and attaches it to pin D3. In the main loop, the servo is instructed to move between 0 and 180 degrees in a sweeping motion. The delay(15) function call ensures that the servo has enough time to reach the desired position before moving to the next one.
