If you know any programming and have never heard of Arduino, you live under a rock. If you don't know any programming its a great place to start. A friend in Peru introduced me to it when he asked me to help him program his beer brewing controller. Since then I've decided that its the best thing to come out of Italy since girls in summer dresses on scooters.
Seriously Arduino is cool. Take a look at diydrones.com very nice stuff all built on Arduino. Trust me I'm saving for one of those Ardupilot Megas.
If you want to get into it HobbyKing seem to have cornered the market on price. They have clones of the Arduino Uno, Arduino Nano and even Arduino Mega. There are also some nice 5/3.3V switchable versions of the nano pro mini on ebay for around $10.
There are loads of resources on Arduino on the internet. To get started go to the Arduino website, read the language reference then follow your internet nose. A personal recommendation Tronixstuff has some great Arduino tutorials.
Arduino is a system for making it easier to program micro controllers. Arduino refers to both the programming environment (Arduino IDE) and Arduino hardware all of which is currently based on the ATMega series of micro controllers. You guessed it, the same micro controllers that you find in most of the Multi-Rotor control boards out there, a number of ESCs, and even the Turnigy 9x.
The great thing about the Arduino IDE is that it is open source. Which makes it easy for us to hack and make it work with our multi-rotor control board.
What you need:
A USBasp programmer.
The HK 3.0 Controller board. (you could also adapt this to other boards)
No drivers are needed for Linux or OSX.
Windows get your drivers from here you have to manually install the drivers. Josh on Flite Test shows how to install the drivers on Windows 7, and also how to use KKMultiTool on a HK controller board. Worth a look.
Get it first of course. Now we need to find the boards.txt file and add an entry for the HK controller board.
Mac users control click on arduino.app and show package contents. Then follow the path to the boards.txt file.
Windows users, its in the Arduino folder under hardware\arduino
Open it with your favorite text editor and add this to the top of it:
Now navigate to Contents/Resources/Java/hardware/arduino/variants/ (hint the variants folder is right next to the boards.txt file).
We want to make a new variant based on the standard variant.
Make a copy of the whole standard folder and rename it to hobbyking_v3.
Again with your favorite text editor. Open the pins_arduino.h file that is inside your newly created hobbyking_v3 folder.
We are going to add two entries to two arrays in order to make use of two digital pins on the Atmega that Arduino does not use.
After line 152 add the following two lines.
Also after line 175 add these two lines.
You should end up with something looking like this.
Thats it, save it and your done hacking the IDE.
Here is some example code, paste it in.
I am making use of the Arduino servo library and simply taking the output from the gyros and feeding it to the servos. The reason I used consts rather than #defines is a good habit from my software engineering days. It can help to avoid hard to find bugs as the compiler processes the symbols rather than the preprocessor.
Once you have the above code pasted in you can upload it to your board.
Plug in your programmer to your board like this:
You should have the Hobbyking V3.0 Atmega328 listed under Tools->Boards. Select it.
Also select USBasp as your programmer. Tools->Programmer->USBasp
Plug in your programmer to your computer and upload the code using File->Upload using programmer. Using the standard upload button will not work.
Done. To play with it unplug your programmer stick a servo in M1 and M2 and provide power using 5V from a UBEC anywhere else.
Now use your imagination to find something cool to do with it. Try reading the values from the pots to to make a simple servo tester.
For your reference I have include the diagrams I made to figure the code out. The datasheet for the angular rate sensors is also at the bottom.