Circuit Documentation
Summary of the Circuit
This circuit consists of an Arduino UNO microcontroller board that is used to control a servo motor. The servo motor is connected to the Arduino UNO via three connections: power (5V), ground (GND), and control signal (pulse). The control signal is provided through one of the digital I/O pins of the Arduino UNO (pin D9). The Arduino UNO is programmed to move the servo motor smoothly between 0 and 180 degrees, creating a sweeping motion.
Component List
Arduino UNO
- Description: A microcontroller board based on the ATmega328P.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0-A5, SCL, SDA, AREF, D0-D13.
- Purpose: Acts as the main controller for the circuit, providing logic and control signals to the servo motor.
Servo Motor
- Description: An actuator that can be precisely controlled for angular or linear position, velocity, and acceleration.
- Pins: gnd, vcc, pulse.
- Purpose: Executes physical movements based on control signals from the Arduino UNO.
Wiring Details
Arduino UNO
- 5V connected to Servo Motor VCC.
- GND connected to Servo Motor GND.
- D9 connected to Servo Motor Pulse.
Servo Motor
- VCC connected to Arduino UNO 5V.
- GND connected to Arduino UNO GND.
- Pulse connected to Arduino UNO D9.
Documented Code
/*
* This Arduino sketch controls a servo motor connected to pin D9 of an Arduino UNO.
* The servo will smoothly move between its open and closed positions.
*/
#include <Servo.h>
Servo myServo; // create servo object to control a servo
void setup() {
myServo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop() {
// Move servo from 0 to 180 degrees
for (int pos = 0; pos <= 180; pos += 1) {
myServo.write(pos); // move servo to 'pos' degrees
delay(15); // wait for 15 milliseconds to create a smooth motion
}
// Move servo from 180 to 0 degrees
for (int pos = 180; pos >= 0; pos -= 1) {
myServo.write(pos); // move servo to 'pos' degrees
delay(15); // wait for 15 milliseconds to create a smooth motion
}
}
Filename: sketch.ino
Description: The code defines the behavior of the servo motor connected to the Arduino UNO. It includes the Servo library and defines a Servo object named myServo. In the setup() function, the servo motor is attached to digital pin 9. The loop() function contains two for loops that move the servo motor from 0 to 180 degrees and back, with a 15-millisecond delay between each degree to create a smooth motion.
