Site icon Circuit Ideas for You

Smooth Servo Rotation Circuit with Arduino and Potentiometer

This project shows about Smooth Servo Rotation Circuit with Arduino and Potentiometer, just turn the knob and see servo arm moves smooth from 0° to 180°.

Circuit is easy and fun to learn how Arduino reads analog signal and makes motion; also its a good project for beginners in robotics, automation or motor control.

Arduino Code:

#include <Servo.h>
Servo myservo;
int potPin = A0;
int val;

void setup() {
myservo.attach(9);
}

void loop() {
val = analogRead(potPin);
val = map(val, 0, 1023, 0, 180);
myservo.write(val);
delay(15);
}

Coding Explanation:

Circuit Working:

Smooth Servo Rotation Circuit Diagram with Arduino and Potentiometer.

Parts List:

ComponentsQuantity
SG90 Servo Motor1
Arduino Mega 25601
Potentiometer 20k1

Potentiometer gives analog voltage between 0V and 5V and then Arduino reads this voltage using analog pin A0.

The Arduino converts the input into a value between 0 and 1023 and maps this value to a servo angle between 0 and 180 degrees.

Therefore, when we rotate the potentiometer then the servo moves accordingly.

Formula with Calculation:

Below is the formula for Potentiometer output voltage = (Position / Full rotation) × 5V

Arduino analog value = (Voltage / 5V) × 1023

Example:

If potentiometer gives 2.5V then,

Analog value = (2.5 / 5) × 1023 = 511

Mapped servo angle = (511 / 1023) × 180 = 90 degrees

How to Build:

To build a Smooth Servo Rotation Circuit with Arduino and Potentiometer follow the below steps for connection:

Conclusion:

To conclude, Smooth Servo Rotation Circuit with Arduino and Potentiometer is simple and easy to give it a try; here, potentiometer moves servo angle smoothly.

Furthermore, this project teaches analog input and PWM output and is useful in robotic arms, camera control and small automation systems.

Exit mobile version