Categories
Uncategorized

Getting Started with the Atmega32u4 Breakout Board+

Atmega32u4 Breakout Board+

I’ve talked about Adafruit’s Atmega32u4 Breakout Board+ before, first in my post Teensy vs. Atmega32u4 Breakout Board+ and then in the post The Future of Open Source (Part II), so I figured I should actually get a Atmega32u4 Breakout Board+. (Also, I’m just going to call it the Atmega32u4 from now on.)

Now as far as AVR development, I’m a guy who doesn’t like to stray too far from the Arduino world, partly because I find it fun and comfortable, and it does most of what I’ve needed so far. That said, I did end up dabbling with the Teensy for The Button.

Don’t get me wrong, the Teensy is awesome for what it does, and what it is, but occasionally my open source bias takes hold and it bothers me (just a little bit) that the Teensy is not open source. Of course, Adafruit’s Atmega32u4 is open source, which gives it a few more points in it’s favor. Price-wise, the Tensy is $16.00 and the Atmega32u4 is $20.00. Consider it the “open source tax” if you will. (Or buy 100 of them and they’re only $16.00 each then!) (Update: Actually, the Teensy with pins is $19.00 and the Atmega32u4 Breakout Board+ with pins is $20.00, which is even closer in price. You can buy the Teensy without pins at $16.00 but you can’t buy the Atmega32u4 Breakout Board+ without pins.)

So with an Atmega32u4 in hand, and from the perspective of someone who used a Teensy successfully, here’s my review.

Atmega32u4 Breakout Board+ (Close-Up)

You’ll want to start with the Atmega32u4 product page. Without that, I’d still be watching a pulsating LED and swearing.

Read the section titled “Why not use a Teensy” and decide if you really want to use the Atmega32u4 instead. Done? Good. If you still want to use the Atmega32u4, continue reading!

The next section I’d call your attention to is the Using Teensyduino section. As I said, I’m an Arduino guy, so I wanted to give Teensyduino a try. Teensyduino is a software add-on for the Arduino IDE. It adds the ability to build and run sketches on the Teensy. If you don’t want to install avrdude or deal with command line stuff, this is another option. I’m not against using avrdude, but I wanted to try to parallel my Teensy experience, so Teensyduino was part of the toolchain.

I had already installed Teensyduino for use with the Teensy, so the section on that topic was where I jumped in. I walked through the changes, from editing boards.txt to restarting the Arduino IDE. It didn’t work.

But wait! There’s a line that says “Download the Arduino IDE from arduino.cc – as of this tutorial, IDE v21 works best – its not the latest one so scroll down to find it.” And yes, I’m running IDE v22. I’m not sure if that’s what broke things, but rather than download version v21 and try the edits again, I just grabbed the “ready to go” dmg that Adafruit supplied. Since I already had the Arduino IDE in my applications folder, I just renamed it to “ArduinoAtmega32u4” and ran it. It worked!

So the software installation/configuration part was a bit more difficult for the Atmega32u4 than for the Teensy, at first, but not much of an issue in the end.

Atmega32u4

So here’s a simple blink sketch, slightly modified from one that worked with the Teensy. The one issue with the Atmega32u4 is that you need to press the reset button on the board before you upload a sketch. Each time. Adafruit mentions this, so it’s not a surprise, but you just need to remember to do it. If you use a Teensy or an Arduino all the time, you might forget.

Atmega32u4

So the next test was to make the Atmega32u4 emulate a USB keyboard, just like the Teensy can do. You’ll need to change the menu options, but besides that, it worked well. At this point, with everything working, the differences between the Teensy and the Atmega32u4 seem pretty minimal. Granted, I’m not doing anything complex here, but it’s good to know that I could easily swap out the Teensy for the Atmega32u4 in some situations.

Here’s the code I used, which prints a space, similar to what the Teensy does for The Photo Booth:


void setup() {
  Serial.begin(9600);
  delay(4000);
}

void loop() {
  // Your computer will receive these characters from a USB keyboard.
  Keyboard.print(" "); 

  // typing too rapidly can overwhelm a PC
  delay(2000);
}

So now that I’ve got an Atmega32u4, and know what it can do, the only thing left is to let the hacking begin! :)

Categories
Uncategorized

The Button

The Button

NOTE: Need a button? Now you can buy one! Visit our store or Etsy.

I was in need of a button, but not just any button. A USB-enabled button that could emulate a single key being pressed on a keyboard. This is that button…

It consists of the following materials:

The Button

I used a Teensy as it’s a very simple (and cheap!) way to emulate a USB HID. I do wish the Teensy had mounting holes. I ended up not mounting it at all and letting it just hang loose, which should be fine, as it’s so lightweight. There’s a bit of electrical tape wrapped around the Teensy and the solder joints.

For the box, I wanted something metal, so it would be heavier and more sturdy than the typical plastic project box. Matt Gauger of Milwaukee Makerspace suggested I check out Mammoth Electronics, as they make boxes for guitar pedals. I ended up choosing their “tall” enclosure.

For the button, I really like this button over the one I ended up using, but it was too tall to fit in the project box. Unless you’re a “button snob” you probably won’t notice much difference between the two.

If you’ve got USB cables lying around, use one… otherwise, you can get one from Monoprice for less than a dollar. I pretty much buy all my cables from Monoprice.

As for the rubber feet, I picked some up at the local hardware store… as well as some black spray paint. (Note: If you are ordering the button from Sparkfun, just get the rubber feet from them too!)

The Button

There was one more item I needed. The button needs a 27.3 mm hole to fit into, which means I needed a hole that was 1.07480315 inches wide. Well, 1.07480315 inches is pretty close to 1.0 inches, so I ended up getting an Ace Bi-Metal Variable Pitch Hole Saw. (The link is not the exact one that I got. I ended up getting mine at the local Ace Hardware store.)

As for the process, the Teensy part took a small amount of time, (see the AWESOME Button) and the drilling was a little tricky, as the 1.0 inch hole was just slightly too small. A bit of creative drilling with a regular drill bit fixed that though. The spray painting was the real time consuming part of it all. As for the assembly, I originally envisioned mounting the Teensy on the bottom plate of the box, and having a hole where the USB connector would be accessible, but I ended up going with what you see in the photo. (I just used the Dremel to cut a small groove for the cable to fit into.)

And why do I need a yellow button that can emulate a key being pressed? Well, sometimes you just need a yellow button that can emulate a key being pressed…

The Button

Note: A number of people have asked for the code I used, and even though it is in the comments, I thought I should post it in here as well.

/*
 * Button.pde
 */

void setup() {
  Serial.begin(9600);
  pinMode(10, INPUT_PULLUP);
  delay(500);
}

void loop() {
  if (digitalRead(10) == HIGH) {
    delay(10);
  } else {
    Keyboard.print(" "); // we print a space
    delay(1000);
  }
  delay(10);
}
Categories
Uncategorized

Teensy vs. Atmega32u4 Breakout Board+


Photos from Adafruit Industries.

I remember seeing the Teensy when I was digging into Arduino stuff last year, and it looked interesting, mainly due to it being small and cheap. (I like cheap!) But since I’m a lot more interested in what the Arduino has to offer, I didn’t look into the Teensy very much.

The Teensy is interesting though because out of the box it functions as a USB HID device, which means it can very easily emulate a keyboard or mouse. (See this Awesome Button post for a neat example.)

If you didn’t know, I’m a big fan of Adafruit Industries, not just for their amazing customer service and great products, but for their support of the open source movement, especially the work they’ve done with open source hardware. Adafruit actually sells the Teensy, but they also came out with a product called the “Atmega32u4 Breakout Board+” (terrible name, eh?) which is like a Teensy, but not like a Teensy.

Here’s where it gets weird… or interesting… or both…

By all respects, the Teensy is pretty cool, as I said, it’s small, and cheap, and can emulate a USB HID, and if your project needs that, it’s a good fit. See the Teensy page for more info.

Now, the “Atmega32u4 Breakout Board+” (terrible name) by Adafruit is similar but different. You can check out the Atmega32u4 Breakout Board+ page for more info.

Ultimately, I think I’d prefer to use the Atmega32u4 Breakout Board+ from Adafruit, and for a good explanation, see this Adafruit blog post about the Teensy, and for extra credit, see A Brief Essay About the Benefits of Open-Source Hardware.

It’s a shame the Teensy is not open source hardware, as I’d prefer to support vendors of open source hardware.

So I’ve got a project planned, and it will use a Teensy. So why not use a Atmega32u4 Breakout Board+? The first reason is, I don’t think I’m ready for it. In reading through the Atmega32u4 Breakout Board+ docs and digging through the forums a bit, it looks like Atmega32u4 Breakout Board+ development is not exactly easy for a beginner. I’d like to get into it at some point, but right now, the Teensy seems like an easier path to completing my project, and maybe once it’s done I can look into working with the Atmega32u4 Breakout Board+.

I know this may seem like a small thing, but I’d really like to support open source hardware when I can, the same way I try to support open source software when I can. It’s always a struggle.