Close

Servo Control- Arduino Workshop

mr-sarful-hassanMr. Sarful hassan wrote 06/15/2020 at 13:50 • 5 min read • Like
In this very simple project, you will control a single servo using Arduino and a potentiometer. A servo is a motor with a feedback system that helps to control the position of the motor. Servos typically rotate through 180 degrees, although you can also buy continuous rotation servos or even modify a standard one for continuous rotation. If you have ever owned a radio-controlled (RC) airplane, you have come across servos; they are used to control the flight surfaces. RC cars use them for the steering mechanism, and RC boats use them to control the rudder. Likewise, they are often used as the moving joints in small robot arms and for controlling movement in animatronics. Servos are really easy to control thanks to the servo library that comes with the Arduino IDE.

Required Component :

1.Arduino 2. Resistors 3. Standard RC Servo 4.Potentiometer 5. connecting wire 6. Breadboard

This book will help you to gain more knowledge about Arduino

Beginning Arduino

Circuit diagram Servo Control Arduino  :

You will need to obtain a standard RC servo; any of the small or mid-sized servos will do. The servo must be powered by its own power supply. Do not power it from the Arduino’s 5V supply as this will cause both noise and excessive heat, potentially disrupting the program or worse, damaging the Arduino. Use an external 5V supply or a battery pack. Make sure the ground of both the Arduino and the power supply is connected. Also, add a resistor in series between the Arduino’s output and the control input of the servo to limit current if the Arduino is on when the servo’s supply is off. A 220-ohm resistor will do here. Also, you’ll need a potentiometer; pretty much any value rotary potentiometer will do. I used a 4.7K ohm one for testing. Note that you may also wish to connect your Arduino to an external DC power supply Servo Control The servo has three wires coming from it. One will be red and will go to +5V. One will be black or brown and will go to the ground. The third will be white, yellow, or orange and will be connected to digital pin 5 via a 220-ohm resistor. The rotary potentiometer has the outer pins connected to +5V and ground and the middle pin to analog pin 0. Once everything is connected as it should be, enter the code below.

Code  Servo Control Arduino  :

#include <Servo.h>
Servo servo1; // Create a servo object
void setup()
{
servo1.attach(5); // Attaches the servo on Pin 5 to the
servo object
}
void loop()
{
int angle = analogRead(0); // Read the pot value
angle=map(angle, 0, 1023, 0, 180); // Map the values from 0
to 180 degrees
servo1.write(angle); // Write the angle to the servo
delay(15); // Delay of 15ms to allow servo to reach position
}

All Arduino tutorial available Click here

 ALL ARDUINO TUTORIAL 

Like

Discussions