Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Battery-Powered Servo Control System with Potentiometers

View and Edit Project In Cirkit DesignerImage of Arduino UNO Battery-Powered Servo Control System with Potentiometers

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

Servo

Potentiometer

Arduino UNO

Wiring Details

9V Battery

Servo

Potentiometer

Arduino UNO

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.