Wednesday, February 8, 2012

Playing with Arduino


Learning how to use an Arduino board is a straight forward process if you follow the tutorials on Arduino page (http://arduino.cc/en/Tutorial/HomePage). You just need some basic programming skills and some basic electronic knowledge; the tutorials put everything on a very simple way.

The Arduino Environment is a higher level code based on C++ for microcontrollers; there are many libraries that cover the low level setup. For example if you use the PWM (Pulse With Modulation) library, you just have to specify the duty cycle of it; frequency of the signal is a fixed value, you can't change it easily unless you go the C++ code. This implies that Arduino code is less flexible but it also makes it a lot (really a lot!) easier to use.

After doing a lot of the examples on the tutorials, my objective was to control the servo motors to be used on my robot. So I used the servo library from Arduino to control the position of 1 servo by manipulating a potentiometer, then the same for 2 servos and then for all the 5 servos.

As I mentioned on the previous post, the Arduino Uno board can source up to 2 servos; so for sourcing all the 5 servos I used an external 5V power supply. Be careful that if you use a wall adapter power supply, not to buy any cheap one because it can be very inaccurate on the voltage it says to provide.

Then I created a costume sequence with the servos, that's a bit trickier since you have to code each servo position separately, thus you have to know where every servo should be at every moment of the sequence. This exercise is very useful since it's something pretty similar than controlling the robotic arm in an open loop project.

You can take a look at how the servos worked on the following video:


Next step will be to build the mechanical part of the robot and create some sequence for it, so that the arm can show off.