Find fresh tutorials related to Arduino, Raspberry Pi, 555 Timer and many more microcontrollers. Learn something new everyday!



Saturday 31 January 2015

Controlling micro servos using Arduino [ARDUINO]


So, by now you should have learnt how to control different things using HC-05 bluetooth module. Bluetooth becomes really convenient in home automation, because, it's simple. Especially controlling relays becomes very easy.

Now, let's shift our attention towards the mechanical side of electronics. Yeah, I'm talking about servos and motors. Servos, undoubtedly have many real life applications.
Servos come cheap. I ordered a few TowerPro Micro Servos for $4 each from Ebay. Maybe you'll find cheaper ones than these.

Yesterday I received these two cute little servos. The first thing that amazed me was the size. Check the image below:

The SG90 alongside a Rs.5 coin


Something about servos:
Simply put, a servo is a DC motor, but wait. Don't be mistaken.
It's a motor, which comes with several integrated gears that can be precisely controlled using sophisticated MCUs. This means, unlike a DC motor, whose only controllable parameter is the speed(by changing the voltage across it), a servo motor's shaft can be precisely controlled to a particular angular position. Read more about it on Wikipedia.

Given below is a simple 9g micro servo, with voltage requirements of 4.8V shown alongwith its horns and screws.

The micro servo with its attachments


What this project does?
Teaches you the simplest program to control a servo using arduino. This program will simply rotate the horn of your servo by 180 degrees CW and ACW.

Materials Required:
1. A 9g micro servo
2. Arduino
3. Jumpers
4. Breadboard
5. and of course, a PC with Arduino IDE installed!

Procedure:

Software part:
1. Upload the sketch given below.

Hardware part:
1. Connect the components as shown:

Schematics
2. Power on the Arduino.

WARNING: DON'T ATTACH MORE THAN TWO SERVOS DIRECTLY TO THE ARDUINO BOARD. USB CAN'T PROVIDE ENOUGH POWER FOR THEM. 

Sketch:
The sketch is the same one on official arduino site. Click here for the code

How this works (Algorithm):
The arduino is given the position feedback via its internal circuitry. The PWM pin 9 of the arduino varies the voltage and thus rotates the shaft accordingly.


Something for you!
Try these ideas to enhance your knowledge and test yourself:
1. Make a bluetooth operated servo controller.
2. Make a servo controller using two push button switches that rotate the servo either clockwise or anticlockwise.

The servos have a variety of applications including robotic arms to complete robots. Bipeds, Quadrupeds, etc implement the use of these servos. Several servo related projects will soon follow. Keep checking out electro.nitishdash.com everyday!


2 comments:

Leave your valuable feedback and suggestions.

Upcoming projects!

1. Programming ESP8266 using NodeMCU and LUA Scripts

2. IoT Applications

3. NRF42L01 2.4 GhZ module interfacing with arduino

4. ESP8266 - Everything cool about it!

Language ain't any barrier!

Get Updates!

Enter your email address:


Get the latest projects delivered into your inbox, hot!