Smart IxD Lab

Menu

Thoughts, observations and experimentation on interaction by: Smart Design

Check us out

Folks at the interaction lab recently have been playing with the LUFA framework.  LUFA is an “open source complete USB stack for USB-enabled Atmel Microcontrollers”.  This basically means with LUFA you can turn an Arduino into a keyboard, mouse, joystick, or other USB devices. Awesome!

There are tons of ways to get LUFA onto your Arduino.  We found it easiest to use Darran Hunt’s LUFA hex files (which he already pre-compiled) posted on his website and load it via an AVR Programmer.  If you’re interested in trying our process download the sample project (which is based off of Darran’s work). It contains a keyboard hex file, the original arduino hex file, and a sample arduino sketch.

You will also need:

  • Crosspack
  • AVR Programmer (we used an AVR MKII)
  • Arduino Uno

Here’s the steps for creating a LUFA Keyboard.

1. Download and install Crosspack. This will give you the ability to run avrdude, which you will need to flash to your Arduino.

2. Load LUFA_Sketch from our sampe project onto your Arduino. It is important you do this step first since once you do step 3 your Arduino won’t be recoginized by the IDE anymore.  Don’t worry, we’ll go over how to get it back in step 6.

3. Hook up your Arduino like so.  Open up terminal and navigate to the folder.  Once there, run the following command to flash the new hex:

avrdude -p at90usb82 -F -P usb -c avrispmkii -U flash:w:arduino-keyboard-0.3.hex -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m

Once it is done (should take less than 10 seconds), unplug the USB cables and AVR Programmer.

4. Now, wire up your Arduino so that there’s a button connected to pin 2.  Re-plug in your Arduino and computer should say it has detected a new Keyboard device.

5. Open up your favorite text editor and press the button.  You should see “w”‘s being typed.

6. I mentioned that once you load LUFA onto your Arduino you won’t be able to load a new sketch since it is no longer recognized by the Arduino IDE.  To load a new sketch you need to re-flash the original Arduino firmware (which is included in the sample project).  So hook up the AVR Programmer as in step 3 and run the following command

avrdude -p at90usb82 -F -P usb -c avrispmkii -U flash:w:UNO-dfu_and_usbserial_combined.hex -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m -U efuse:w:0xF4:m -U lock:w:0x0F:m

Once done your Arduino will be recognized by the IDE again.

Happy Hacking!

Posted by: Carla Diana

Leave a comment

Your email address will not be published. Required fields are marked *