UPDATE: this article was originally written to work with Arduino 1.01 and the KK2.0. The KK2 is now up to 2.1 it has an ATMega624 and a slightly different I2C gyro (demo program is not updated for this yet). I have updated the document to work with the newer KK2 however I recommend that you still use the older version of Arduino.
Originally designed for multi rotors, the KK2 Multicontroller makes for a very cheap Arduino compatible board with a little bit of hacking.
For $30 you get an ATMega324 MCU, a 128x64 graphical LCD, 4 buttons, 14 GPIO pins, 3 axis gyroscope and 3 axis accelerometer.
The kk2.1 has an or ATMega644 which has twice the amount of Flash, Ram and EEProm storage on board.
Great for any motion based project that requires a simple user interface.
Video demonstrating the Arduino test code.
Detailed explanation of the Arduino test code.
Hacking the Arduino IDE.
UPDATE: Robert and Erikas had pointed out that I made a few errors in this tutorial. (Thanks guys) Fortunately they figured it out. I have since made some changes so hopefully no more mistakes here.
If you have not already got one you can buy the KK2 from HobbyKing. They are popular and sometimes out of stock so here are a few links:
Windows use a code editor, or failing that wordpad. Notepad cannot handle the Unix carriage returns in this file.
Search for ATMega324 to find this part of the document.
We need to change the signature from 0x1e 0x95 0x08 to 0x1e 0x95 0x11.
Step 4. Add the LCD library.
Download the KK2LCD library from the bottom of this article. Unzip it.
As long as you have opened Arduino at least once you should have an Arduino directory in your documents folder.
If there is no libraries folder in the Arduino directory create it.
Then put the KK2LCD folder inside that. Alternatively you can unzip the library in the library folder.
It should look something like this:
Step 5. Connect your programmer and KK2.
Easy, like this:
Step 6. Upload the example code to your KK2.
Make sure all the edited documents are saved and closed.
Quit Arduino and then open it again.
Do the following in the Arduino menu:
File->Upload Using Programmer
If all went well you should have the example program running on your KK2.
Step 7. Hack away.
Feel free to copy and modify my example code below (it is also included in the KK2LCD library). Remember to always upload using the Upload Using Programmer option as the regular upload button will not work.
//Arduino on the KK2 test code by Marc Griffith is licensed under a Creative Commons Attribution 3.0 Unported License.
Graphics!. A delve into the openAero code and some that KaptienKuk posted has helped get this working.
installing LCD Assistant.
windows, no installation needed, just run it.
MacOSX, macports, wine, and run with wine.
Important, Arduino code use external analog reference. otherwise when you try to do an analog read it will short out and reset, lucky no damage. This took a while to figure out but the details are buried in the datasheet.
None of the output pins have PWM, so KaptienKuk does it all in software. The PWM pins seem to be wasted on the buttons and LCD interface. There are 8 PWM pins available, not sure why KK did not use them all for the outputs. Must be a good reason.
UPDATE. Correction, there are 6 PWM pins available (thanks to Ciskje from Italy). I can see now the reason.
Other comms methods are available which means opportunities for expansion. Perhaps KK has a GPS, Magnetometer or Baro add on in mind?
Serial connections exposed, RX0, TX1 and RX1. TX0 is used on the LCD interface. But Serial1 can be used to talk to a computer via an FTDI chip for example.
I2C is available on the output headers.
SPI can be used as a master but the Slave Select pin is on one of the buttons.