Arduino UNO Battery-Powered Servo Control System with Potentiometers
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit consists of an Arduino UNO microcontroller, four servos, four potentiometers, and a 9V battery. The potentiometers are used to control the position of the servos. The Arduino reads the analog values from the potentiometers and maps these values to servo positions, which are then sent to the servos to control their movement.
Component List
9V Battery
- Description: Provides power to the circuit.
- Pins:
+,-
Servo
- Description: Actuator that rotates to a specific position based on the input pulse width.
- Pins:
gnd,vcc,pulse
Potentiometer
- Description: Variable resistor used to provide an adjustable voltage output.
- Pins:
GND,Output,VCC
Arduino UNO
- Description: Microcontroller used to read analog inputs from the potentiometers and control the servos.
- 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
Wiring Details
9V Battery
+ connected to:
- Potentiometer
VCC(4 instances) - Servo
vcc(3 instances)
- Potentiometer
- connected to:
- Potentiometer
GND(4 instances) - Servo
gnd(4 instances)
- Potentiometer
Servo
gnd connected to:
- 9V Battery
-(4 instances)
- 9V Battery
vcc connected to:
- 9V Battery
+(3 instances) - Potentiometer
VCC(1 instance)
- 9V Battery
pulse connected to:
- Arduino UNO
D12(1 instance) - Arduino UNO
D11(1 instance) - Arduino UNO
D10(1 instance) - Arduino UNO
D9(1 instance)
- Arduino UNO
Potentiometer
GND connected to:
- 9V Battery
-(4 instances)
- 9V Battery
Output connected to:
- Arduino UNO
A3(1 instance) - Arduino UNO
A1(1 instance) - Arduino UNO
A2(1 instance) - Arduino UNO
A0(1 instance)
- Arduino UNO
VCC connected to:
- 9V Battery
+(4 instances) - Servo
vcc(1 instance)
- 9V Battery
Arduino UNO
D12 connected to:
- Servo
pulse(1 instance)
- Servo
D11 connected to:
- Servo
pulse(1 instance)
- Servo
D10 connected to:
- Servo
pulse(1 instance)
- Servo
D9 connected to:
- Servo
pulse(1 instance)
- Servo
A3 connected to:
- Potentiometer
Output(1 instance)
- Potentiometer
A1 connected to:
- Potentiometer
Output(1 instance)
- Potentiometer
A2 connected to:
- Potentiometer
Output(1 instance)
- Potentiometer
A0 connected to:
- Potentiometer
Output(1 instance)
- Potentiometer
Code Documentation
#include <Servo.h>
Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;
const int potPin1 = A0;
const int potPin2 = A1;
const int potPin3 = A2;
const int potPin4 = A3;
const int servoPin1 = 9;
const int servoPin2 = 10;
const int servoPin3 = 11;
const int servoPin4 = 12;
void setup() {
servo1.attach(servoPin1);
servo2.attach(servoPin2);
servo3.attach(servoPin3);
servo4.attach(servoPin4);
}
void loop() {
int potValue1 = analogRead(potPin1);
int potValue2 = analogRead(potPin2);
int potValue3 = analogRead(potPin3);
int potValue4 = analogRead(potPin4);
int servoPos1 = map(potValue1, 0, 1023, 0, 180);
int servoPos2 = map(potValue2, 0, 1023, 0, 180);
int servoPos3 = map(potValue3, 0, 1023, 0, 180);
int servoPos4 = map(potValue4, 0, 1023, 0, 180);
servo1.write(servoPos1);
servo2.write(servoPos2);
servo3.write(servoPos3);
servo4.write(servoPos4);
delay(15); // Small delay to allow servos to reach the position
}
This code initializes four servo objects and four potentiometer pins. In the setup function, each servo is attached to a specific digital pin on the Arduino. In the loop function, the analog values from the potentiometers are read, mapped to a range suitable for the servos, and then written to the servos to control their positions. A small delay is added to allow the servos to reach their positions smoothly.