• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Circuit Ideas for You

Get free circuit ideas online.

  • Home
  • Privacy Policy
  • About
Home » Simple Servo Motor Controller Circuit using Arduino

Simple Servo Motor Controller Circuit using Arduino

Last updated on 22 August 2024 by Admin-Lavi Leave a Comment

Servo motors are flexible parts used in many different applications since they are electromechanical actuators that have the ability to rotate to a certain position.

Applications for servomotors include automated manufacturing, robotics, and CNC equipment, etc.

This post will examine how to use an Arduino microcontroller to drive a servo motor while adding push buttons, capacitors, resistors and an IC 7809 voltage regulator.

Coding with Explanation:

#include <Servo.h>

Servo myservo;  // Create a servo object

int servoPin = 9;  // Pin connected to the servo signal
int button1Pin = 2;  // Pin connected to the first push button
int button2Pin = 3;  // Pin connected to the second push button

int angle = 0;  // Initial servo angle

void setup() {
  myservo.attach(servoPin);  // Attach the servo to the specified pin
  pinMode(button1Pin, INPUT);  // Set the push button pins as input
  pinMode(button2Pin, INPUT);
}

void loop() {
  int button1State = digitalRead(button1Pin);
  int button2State = digitalRead(button2Pin);

  if (button1State == HIGH) {
    angle += 1;  // Increment the angle
    if (angle > 180) {
      angle = 180;  // Limit the angle to 0-180 degrees
    }
  } else if (button2State == HIGH) {
    angle -= 1;  // Decrement the angle
    if (angle < 0) {
      angle = 0;  // Limit the angle to 0-180 degrees
    }
  }

  myservo.write(angle);  // Set the servo's position
  delay(15);  // Delay for smooth movement
}
  • The code specifies a starting angle, push button pins, and the servo pin.
  • The push button pins are set to input and the servo is connected to the designated pin in the setup() method.
  • States of the push buttons are read by the loop() method.
  • The angle is increased when button 1 is pressed and decreased when button 2 is pressed.
  • The range of angles is 0 to 180 degrees.
  • Lastly, the myservo.write() method is used to set the servos position.

Circuit Working:

Parts List:

ComponentQuantity
Arduino Uno board1
IC 78091
Capacitor 100μF 25V1
Resistors 1/4 watt 100k2
Servo Motor1
Tactile Switches2

In this article when necessary, the servo motor or other components can be powered by the 9V voltage that the IC 7809 controls.

Make sure there is a common ground between the servo motor and the Arduino.

To regulate the position of the servo motor, the Arduino employs Pulse Width Modulation PWM on the control pin.

The servo angle is determined by the pulse width.

To read the push button states and adjust the servo accordingly, write a sketch or program.

For instance, pushing one button may cause the servo to move in one direction, whereas pressing another would cause it to go in a different direction.

The Arduino reads the status of each button1 and button2.

The input pin reads LOW when a button is pressed because of the connection to ground.

The pull-up resistor causes the input pin to read HIGH when it is not tapped.

Make sure the voltage regulator is operating steadily, and keep noise levels down that can impact the servo motors efficiency.

The circuits clean, steady power supply is facilitated by the resistors and capacitor.

How To Build:

To build a Simple Servo Motor Control Circuit using Arduino following are the connections steps to follow:

  • Gather all the components mentioned in the above circuit diagram.
  • Connect a regulated IC1 7809 to provide a regulated 9V DC to the Arduino board
  • Connect the ground of the servo motor to the ground pin on the Arduino.
  • Connect the 5V power supply from the Arduino to the servos power input.
  • Connect the signal pin (PWM pin) of the servo to a digital output pin 9 on the Arduino.
  • Connect capacitor 100μF 25V one end to 5V power supply on Arduino board and other end to ground
  • Connect one leg of button1 to pin 2 on the Arduino board and other other leg to ground and connect button2 to pin 3 on the Arduino board and other other leg to ground.
  • Connect one resistor 100k to pin 2 and 5V power supply on Arduino board and connect second resistor 100k to pin3 and 5V power supply on Arduino board.

Conclusion:

These instructions in the article will let you use an Arduino microcontroller to operate a servo motor.

Push buttons, resistors, capacitors and an IC 7809 are added to improve the circuits usefulness and stability, giving it a flexible foundation for a range of applications.

References:

Control a servo motor with a 2 connection toggle switch (on/off switch)

Filed Under: Arduino Projects, Motor Controllers

About Admin-Lavi

Lavi is a B.Tech electronics engineer with a passion for designing new electronic circuits. Do you have questions regarding the circuit diagrams presented on this blog? Feel free to comment and solve your queries with quick replies

Previous Post: « Simple Arduino LED Dimmer Circuit using PWM
Next Post: Simple Heartbeat Monitor Circuit using Arduino »

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Categories

  • Alarm Circuits (30)
  • Amplifier Circuits (67)
  • Arduino Projects (29)
  • Audio Circuits (93)
  • Automobile Circuits (19)
  • Battery Charger Circuits (48)
  • Free Energy (13)
  • Heater and Temperature Controllers (9)
  • Indicator Circuits (38)
  • Inverter Circuits (13)
  • LDR Circuits (13)
  • LED and Lamps (111)
  • Meters and Testers (27)
  • Motor Controllers (18)
  • Oscillator Circuits (32)
  • Power Supply Circuits (91)
  • Remote Control Circuits (6)
  • Security and Protection (23)
  • Sensors and Detectors (71)
  • Solar Circuits (16)
  • Timer Circuits (27)
  • Transistor Circuits (56)
  • Transmitter Circuit (12)
  • Tutorials (4)
  • Water Level Controller (4)

Copyright © 2025 | New Circuit Ideas