I spent the summer working with a new hobby of mine, Quadcopters =D! The quadcopter board is homemade (atmega32u4). Because my board has the same pinout as a leonardo, I decided to go with the multiwii firmware. So I etched a shield for my board containing headers for the receiver, motors and the IMU (cheap chinese found on ebay, ADXL345, L3G4200D, HMC5883 and BMP085).
I was happy with the quadcopter, it flew very nicely (after some PID changes of course).. But in the end I'm the type that likes to write my own code.. Trying to look at multiwii's code to see how they made it work (just to get a hunch), I directly noticed that the code isn't very, hmm how do I put it, reader friendly... So I trashed Multiwii, and there my summer began learning the dynamics and physics of quadcopters.
Three days later, I got a working code.. Three weeks after that I finally managed to find the optimal PID values for my quadcopter =P (yes it took three weeks of tweaking)..
Anyhow I'm not going to bore you out with my story. Instead I'm going to share my code with the arduino community and a video of the quadcopters first flight with my code..
If there is a big demand for a code explanation/theory about quadcopters and how everything works, shout out here, and I'll come up with something for you...
Here is the code: GitHub - baselsw/BlueCopter: Arduino Quadcopter firmware
See attachment for pinout..
And here is the video:
Edit: I've updated the code.. Made the sketch run more efficiently and reduced code size.. With this change I managed to find better PID values and thus get better/faster stabilization.. For those interested I've added pictures of the main board and hardware setup..