Arduino UNO Controlled Robotic Arm with Multiple Servo Motors
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is designed to control multiple servo motors using an Arduino UNO microcontroller. The servos are connected to various digital pins on the Arduino, and the Arduino is programmed to move the servos in a coordinated manner to simulate movements such as head turning, arm lifting, elbow bending, leg raising, and knee bending.
Component List
Servo Motors (10x)
- Pins: gnd, vcc, pulse
- Description: Standard servo motors used for various movements in the circuit.
- Purpose: These servos are used to control different parts of a robotic body, including the head, shoulders, elbows, pelvis, and knees.
Arduino UNO
- 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
- Description: A microcontroller board based on the ATmega328P.
- Purpose: The Arduino UNO is used to control the servo motors by sending PWM signals to their pulse pins.
Wiring Details
Servo Motor 1
- Pin Connections:
- gnd: Connected to GND on Arduino UNO
- vcc: Connected to 5V on Arduino UNO
- pulse: Connected to D4 on Arduino UNO
Servo Motor 2
- Pin Connections:
- gnd: Connected to GND on Arduino UNO
- vcc: Connected to 5V on Arduino UNO
- pulse: Connected to D5 on Arduino UNO
Servo Motor 3
- Pin Connections:
- gnd: Connected to GND on Arduino UNO
- vcc: Connected to 5V on Arduino UNO
- pulse: Connected to D6 on Arduino UNO
Servo Motor 4
- Pin Connections:
- gnd: Connected to GND on Arduino UNO
- vcc: Connected to 5V on Arduino UNO
- pulse: Connected to D3 on Arduino UNO
Servo Motor 5
- Pin Connections:
- gnd: Connected to GND on Arduino UNO
- vcc: Connected to 5V on Arduino UNO
- pulse: Connected to D2 on Arduino UNO
Servo Motor 6
- Pin Connections:
- gnd: Connected to GND on Arduino UNO
- vcc: Connected to 5V on Arduino UNO
- pulse: Connected to D7 on Arduino UNO
Servo Motor 7
- Pin Connections:
- gnd: Connected to GND on Arduino UNO
- vcc: Connected to 5V on Arduino UNO
- pulse: Connected to D8 on Arduino UNO
Servo Motor 8
- Pin Connections:
- gnd: Connected to GND on Arduino UNO
- vcc: Connected to 5V on Arduino UNO
- pulse: Connected to D10 on Arduino UNO
Servo Motor 9
- Pin Connections:
- gnd: Connected to GND on Arduino UNO
- vcc: Connected to 5V on Arduino UNO
- pulse: Connected to D9 on Arduino UNO
Servo Motor 10
- Pin Connections:
- gnd: Connected to GND on Arduino UNO
- vcc: Connected to 5V on Arduino UNO
- pulse: Connected to D4 on Arduino UNO
Documented Code
#include <Servo.h>
// Create servo objects for the parts of the body
Servo headServo; // Servo for head
Servo shoulderL; // Left shoulder servo
Servo shoulderR; // Right shoulder servo
Servo elbowL; // Left elbow servo
Servo elbowR; // Right elbow servo
Servo pelvisL; // Left pelvic joint
Servo pelvisR; // Right pelvic joint
Servo kneeL; // Left knee joint
Servo kneeR; // Right knee joint
void setup() {
// Attach the servos to their corresponding pins
headServo.attach(2); // Head on pin 2
shoulderL.attach(3); // Left shoulder on pin 3
shoulderR.attach(4); // Right shoulder on pin 4
elbowL.attach(5); // Left elbow on pin 5
elbowR.attach(6); // Right elbow on pin 6
pelvisL.attach(7); // Left pelvis on pin 7
pelvisR.attach(8); // Right pelvis on pin 8
kneeL.attach(9); // Left knee on pin 9
kneeR.attach(10); // Right knee on pin 10
}
void loop() {
// Head movement: move left and right
for (int pos = 0; pos <= 90; pos++) { // Sweep head left to right
headServo.write(pos); // Move head
delay(20);
}
for (int pos = 90; pos >= 0; pos--) { // Sweep head right to left
headServo.write(pos); // Move head
delay(20);
}
// Shoulder movement: lift and lower arms
for (int pos = 45; pos <= 135; pos++) {
shoulderL.write(pos); // Move left shoulder
shoulderR.write(180 - pos); // Move right shoulder (opposite)
delay(20);
}
for (int pos = 135; pos >= 45; pos--) {
shoulderL.write(pos); // Move left shoulder
shoulderR.write(180 - pos); // Move right shoulder (opposite)
delay(20);
}
// Elbow movement: bend and straighten elbows
for (int pos = 0; pos <= 90; pos++) {
elbowL.write(pos); // Bend left elbow
elbowR.write(180 - pos); // Bend right elbow
delay(20);
}
for (int pos = 90; pos >= 0; pos--) {
elbowL.write(pos); // Straighten left elbow
elbowR.write(180 - pos); // Straighten right elbow
delay(20);
}
// Pelvic joint movement: raise and lower legs
for (int pos = 90; pos <= 150; pos++) {
pelvisL.write(pos); // Raise left leg
pelvisR.write(180 - pos); // Raise right leg (opposite)
delay(20);
}
for (int pos = 150; pos >= 90; pos--) {
pelvisL.write(pos); // Lower left leg
pelvisR.write(180 - pos); // Lower right leg (opposite)
delay(20);
}
// Knee movement: bend and straighten knees
for (int pos = 0; pos <= 90; pos++) {
kneeL.write(pos); // Bend left knee
kneeR.write(180 - pos); // Bend right knee
delay(20);
}
for (int pos = 90; pos >= 0; pos--) {
kneeL.write(pos); // Straighten left knee
kneeR.write(180 - pos); // Straighten right knee
delay(20);
}
}
This code initializes and controls the servo motors connected to the Arduino UNO. The setup function attaches each servo to its corresponding pin, and the loop function contains the logic for moving the servos in a coordinated manner.