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.
Great for any motion based project that requires a simple user interface.
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:
You will also need a USBasp programmer.
The Arduino IDE codebase is still changing and currently is up to version 1.5. This is mainly to support the newer Due and Leonardo boards.
This tutorial was tested using Arduino 1.01 which can be downloaded from the Arduino download page.
Seeing as your are messing with the IDE it is probably better to keep Arduino 1.01 as a separate copy of the program just for working with the KK2.
I cannot guarantee that this tutorial will work with other versions of Arduino, feel free to try but I see no advantage as yet.
Arduino 1.01 can be downloaded from the Arduino download page.
Drivers for the UBSasp programmer are not needed for OSX or Linux. Windows follow the instructions in my previous article.
To find the boards.txt file.
On OSX control click on Arduino.app then show package contents.
then navigate to Contents/Resources/Java/hardware/arduino
For windows the boards.txt file is under hardware/arduino in the arduino program directory. Open it with wordpad as it handles the unix carriage returns better than notepad.
Add the following section to the boards.txt file and save it.
Find the variant folder.
OSX navigate to.
Download the pins_arduino.h file from the bottom of this article.
Then create a new folder kk2 and place the pins_arduino.h file inside.
You should have something that looks like this:
The code in pins_arduino.h is where all the magic happens. Basically it maps the pins from the ATMega324 to the more familiar Arduino format.
This step is done because the version of AVRDude that is bundled with Arduino does not include the new ATMega324PA chip in its configuration file. Its essentially identical to the ATMega324P so this is an easy fix.
OSX navigate to:
and open avrdude.conf with a text editor.
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.
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:
Easy. I'll add more if people have trouble.
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.
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.
///////////////////////////////////////////////////other disorganised stuff..
unknown MCU 'atmega324pa' specified
solution. edit avrdude.conf. This is ugly but it works.
dont program it with it on your lap!
reset the fuses
avrdude -c usbasp -p m324pa -U lfuse:w:0xf7:m -U hfuse:w:0xd7:m -U efuse:w:0xfc:m -F
avrdude -p m324pa -U lfuse:w:0xe2:m -U hfuse:w:0xd7:m -U efuse:w:0xfc:m -F
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?