šŸŽ›ļøšŸ¤–Controlling the SG90 servo with a potentiometer


šŸ”¹ Components Needed

āœ… Arduino (Uno/Nano/etc.)
āœ… SG90 Servo Motor
āœ… 10kĪ© Potentiometer
āœ… Jumper Wires & Breadboard


šŸ”¹ Circuit Connections

ComponentPinConnect To
SG90 ServoRed (VCC)5V
Brown (GND)GND
Orange (Signal)Pin 9 (PWM)
PotentiometerLeft PinGND
Middle PinA0 (Analog Input)
Right Pin5V

šŸ”¹ Arduino Code (Servo Control with Potentiometer)

#include <Servo.h>

Servo myServo;  // Create servo object
int potPin = A0;  // Potentiometer connected to A0
int potValue;     // Variable to store potentiometer value

void setup() {
    myServo.attach(9);  // Servo signal wire connected to Pin 9
}

void loop() {
    potValue = analogRead(potPin);  // Read potentiometer value (0-1023)
    int angle = map(potValue, 0, 1023, 0, 180);  // Convert to 0-180°
    
    myServo.write(angle);  // Move servo to mapped angle
    delay(15);  // Small delay for smooth movement
}

šŸ”¹ Steps to Run the Code

1ļøāƒ£ Connect everything as per the circuit diagram.
2ļøāƒ£ Upload the code to your Arduino.
3ļøāƒ£ Turn the potentiometer and watch the servo move smoothly! šŸŽ›ļøšŸ¤–


šŸ”¹ What’s Next?

šŸ“”Broadcast the signal — amplify the connection.

Leave a Reply