Site icon Circuit Ideas for You

Simple Servo Motor Controller Circuit using Arduino

Servo motor is small machine part.

It can turn to exact position.

People use it in many things like robots, CNC machines and factory machines.

This post for Simple Servo Motor Controller Circuit using Arduino show how to control servo motor using Arduino.

It also use push buttons, capacitors, resistors and IC 7809 for power.

Coding:

#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
}

Code explanation:

Circuit Working:

Parts List:

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

In this article servo and other parts can get power from 9V using IC 7809.

Servo and Arduino must share same ground.

Arduino uses PWM (Pulse Width Modulation) to control servo position.

Servo angle changes by pulse width.

Write Arduino code to read buttons and move servo.

For example press one button servo goes one way and press other the servo goes the other way.

Arduino check button1 and button2.

When button is pressed input pin read LOW is connected to ground.

When no button is press then pull-up resistor make pin read HIGH.

Ensure voltage regulator work good with less noise the better servo will work.

Resistor and capacitor help give clean and steady power to the circuit.

How To Build:

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

Conclusion:

This article for Simple Servo Motor Controller Circuit using Arduino show to move servo motor.

By using buttons, resistors, capacitor and IC 7809 make circuit more strong and useful.

This circuit is good for many projects.

References:

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

Exit mobile version