Friday, April 30, 2010

Arduino with servo (360deg)

arduino with servo motor (360 deg) 


There are some servo code that came with arduino.
File->examples->servo->sweep


The servo is from parallax. It is a continuous rotation type. Courtesy of Ah Yap, TSO of T822.


I don't have a servo controller handy.... http://www.crustcrawler.com/downloads/manuals/ServoController.pdf
So I would just make do with manually programming my arduino to control 2 servo at a later stage.


The the servo takes 6v and 12mA and we do not want to power it directly off the MCU. If the current load is too high, 
the MCU might be fried. I really take good care of my arduino, so I will try 1x servo instead of 2x.


Just to illustrate the working of it.




Ignore the sonar in the above picture. It is for decoration purposes.
Hook up servo +6v and gnd to arduino 5v and gnd, data to pin D10.


you can try try the example code "SWEEP" that comes with it and for convenience sake, it is attached below.



Check out the servo in action...

Now the questions come begging, how can we drive 2 servo using arduino (note: data pin only) for a forward and backward movement.

4 comments:

Kelvin Khoo said...

You can use the arduino library

ex:
include <"Servo.h">;

Servo leftmotor;
Servo rightmotor;

void setup()
{
leftmotor.attach(9);
rightmotor.attach(10);
}

void loop()
{
leftmotor.write(pwmL + 90);//for use with continuous motor
rightmotor.write(pwmR +90);
}

sjteo said...

@kkky, thanks for the alt ver on using PWM...

Anonymous said...

What means " pwmLp

Anonymous said...

desgraça burra, meta seu pwmL na bunda!