How to run Arduino on the Adafruit atmega32u4 breakout board
I picked up a few of the Adafruit Atmega32u4 breakout boards for a workshop earlier this summer. These are great, inexpensive little devices, but they're only intended for AVR development in C, not Arduino. Adafruit used to support running Teensyduino on these, but they don't anymore, and my attempts to run Teensy on them were really buggy — using the Arduino serial library would cause them to crash, for example.
It turns out that using the Leonardo bootloader is much more reliable. Here's how to get that set up:
- Set up an external programmer. You can't flash the bootloader on the breakout board over USB. You'll need a separate ISP, or you can set up another Arduino as an ISP if you want (follow this tutorial)
- Flash the bootloader. In the Arduino IDE, go to Tools > Programmer, and select the appropriate device. Go to Tools > Board and select Arduino Leonardo. Then click Tools > Burn Bootloader.
- Update references. Changing the bootloader means your pin references in software won't line up properly with your hardware. Compare the schematics (breakout board vs Leonardo), and address the pins as you would on a Leonardo, but connect them according to the atmega32u4 breakout board schematic. Since the breakout board has fewer pins than the Leonardo, naturally you can't use the same range as the Leonardo documentation would tell you.
Here's a pinout diagram for the breakout board running the Leonardo bootloader. Thanks to Nikhil Lal.
If you really, really want to run Teensyduino, you can still find Adafruit's documentation on how to set it up, and this forum thread might help fix problems. Again, they don't recommend doing that, and I ran into a lot of trouble when using standard Arduino libraries.