Arduino UNO Controlled Micro Servo Motor with Dynamic Positioning
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit consists of an Arduino UNO microcontroller and a Micro servo 9G. The Arduino UNO is used to control the Micro servo 9G, which is connected to the Arduino's digital pin D9. The servo motor will move to various positions as specified in the Arduino sketch.
Component List
Arduino UNO
- Description: A microcontroller board based on the ATmega328P.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
Micro servo 9G
- Description: A small servo motor used for precise control of angular position.
- Pins: GND, +5V, PWM
Wiring Details
Arduino UNO
- 5V: Connected to +5V of Micro servo 9G
- GND: Connected to GND of Micro servo 9G
- D9: Connected to PWM of Micro servo 9G
Micro servo 9G
- +5V: Connected to 5V of Arduino UNO
- GND: Connected to GND of Arduino UNO
- PWM: Connected to D9 of Arduino UNO
Code Documentation
Arduino Sketch
/*
* This Arduino sketch controls a micro servo motor connected to pin D9.
* The servo will start at 10 degrees and then move to 130 degrees.
*/
#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
myServo.write(10); // set initial position to 10 degrees
delay(1000); // wait for a second
}
void loop() {
myServo.write(130); // move servo to 130 degrees
delay(1000); // wait for a second
myServo.write(100); // move servo back to 10 degrees
delay(1000); // wait for a second
myServo.write(70); // move servo back to 10 degrees
delay(1000); // wait for a second
myServo.write(40); // move servo back to 10 degrees
delay(1000); // wait for a second
myServo.write(10); // move servo back to 10 degrees
delay(1000); // wait for a second
myServo.write(40); // move servo back to 10 degrees
delay(1000); // wait for a second
myServo.write(70); // move servo back to 10 degrees
delay(1000); // wait for a second
myServo.write(100); // move servo back to 10 degrees
delay(1000); // wait for a second
myServo.write(130); // move servo to 130 degrees
}
This code initializes the servo motor and moves it to various positions in a loop. The servo starts at 10 degrees, moves to 130 degrees, and then cycles through several positions before returning to 10 degrees. Each position is held for one second.