Site icon Circuit Ideas for You

Simple Servo Motor Controller Circuit using Arduino

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
}

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:

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)

Exit mobile version