22.4.09

Teensy = Arduino* (for small quantities of Arduino)

A fair amount of my free time lately has been consumed by getting back into electronics, specifically microcontrollers. I took two years of electronics in high school, and dabbled with it a little after. Life kind of got in the way, and it fell so far to the back burner than it wasn't even warm any more.

I recently became aware of the Arduino development platform, and about the same time another little device called the Teensy. Since then my 'entertainment budget' has been funneled into the bank account of SparkFun for various transistors, switches, regulators, and the all important LEDs; and of course to PJRC for a Teensy... but just what is a Teensy?

The result of a project by Paul Stoffregen, the Teensy is a microcontroller development board based on the Atmel AT90USB162 AVR. The Arduino, also based on Atmel AVRs, differs from the Teensy in a few important ways:

  • The Arduino is 100% open source. While almost everything about the Teensy is open, the bootloader is not.

  • Most Ardunio form factors are MUCH larger than the Teensy. This is good for instant development, as most of them come with header blocks attached so you can just start plugging things in, but it can be limiting when it comes time to put your project into a case.

  • Despite most Arduinos having USB ports, it does not actually do USB communications. A USB/Serial converter is used, which limits the speed at which it can be communicated with.

  • The Teensy, using native on chip USB can, with only a few simple commands, be made to show up as either a USB/Serial device, a mouse, a keyboard, and with a little more work a mass storage device. These can be done with the Arduino, but it's a fair bit more involved.

  • And while the Teensy's older brother Teensy++ also has analog inputs, the original Teensy lacks the Arduino's analog input options. It does have PWM output, though, just as the Arduino, and one can always wire a DAC circuit in if needed.


  • So why Teensy; why didn't I go with the more popular Arduino? There are a lot of reasons I could state, but what it comes down to are two very important ones.

  • Cost... the Teensy is a little cheaper, and having more flash for code storage at less cost, it just made sense to my wallet.

  • Possibly more important... community.


  • "What? The Arduino has a huge community!" Yes, yes it does... and when I bought my Teensy I didn't know ANY OF THEM. I did, though, know someone that had a Teensy. A community of two is much more useful than one of thousands when you know each other personally, and can just show up on the other's door step at any time. I'm a visual learner; five minutes of watching someone else do something is worth weeks of reading about it for me, so having someone in my own little part of the world I could compare notes with if needed played a huge part in my decision.

    The best part is I am not separated from the very large and very active Arduino community. Paul is activly developing what he calls Teensyduino, a plugin for the Arduino IDE that lets most Arduino sketches (the source code for controlling an Arduino, so named because it's based off the Processing programming language whose IDE is called a sketchbook) run with only a little modification. So I get the small form factor, faster communications if I needed it, a local fellow developer, and most of the resources of the Arduino development community for $22 ($19 if you get it without header pins). That's a cost of entry I can deal with.

    Of course it hasn't been all happiness and sunshine. Teensyduino is still in early beta, so some sketches aren't as easy to make work as I'd like just yet. I recently ran into a small issue with serial communications. Specifically the Serial.available() function. Per the Arduino website it should return the number of characters waiting in the buffer to be read. As I don't have an actual Arduino to test the code on I can't be sure, but the example code agrees with the description. On the Teensy (at least as of Teensyduino v0.4) it returns something else, though I'm not sure just what the number means. So I had to come up with a far less elegant solution... the conversation went something like this:

    Me:
    void setup() {
      Serial.begin(9600);
    }

    void loop() {
      if (Serial.available() > 0) {
        Serial.println(Serial.read(), DEC);
      }
    }


    Teensy: -1

    Me: That shouldn't be happening, -1 means there's no data to read, if there's no data Serial.available() should be 0, and you shouldn't be reading.

    Teensy: Whatever...

    Me: Don't give me any lip, I'll reflash you, and do something else.

    Teensy: As if, you're my beotch, and you'll do what I say now.

    Me:
    int receivedByte = 0;

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

    void loop() {
      receivedByte = Serial.read();
      if (receivedByte >= 0) {
        Serial.println(char(receivedByte));
      }
    }


    Teensy: I don't have anything to show you... you need to send me something.

    Me: HA!

    Teensy: Curses, foiled again!


    Yes, that's pretty much how it went... or at least that's how it went in my head. I blame Wil Wheaton... and his iTunes.

    So that's what I've been up to. That work has even fallen over into my still not released write up on GeekTool, which will be out by the end of this week. I just keep finding other things to put in it, so it's never actually done. I guess it's time for a 'feature freeze'.

    4 comments:

    1. Hi Jody!
      Enjoyed your blog. I just discovered teensy from a geek friend, interesting platform, especially the USB stuff. I think I have you trumped in the "elder" category - 58YO, ex-DBA who's been playing with Arduino for a couple of years now, no prior electronics experience or training, just learning by doing and being a good thief. Put together about 10 projects already and some of them even work!

      You have an interesting perspective on teeny vs Arduino, and if it works for you, great. I like the Arduino community because there's lots of documentation, instructions and examples, so I can stand on the shoulders of the pioneers.

      If you like the form-factor of the teensy and want to try something in the Arduino space, check out Modern Device Co. for the Really Bare Bones Board (http://moderndevice.com/RBBB_revB.shtml). I am not associated with them in any way, just like their stuff.

      Keep Learning!

      ReplyDelete
    2. Glad you're enjoying it. Have a few things in the works that I hope to have posted within the new few weeks.

      Yeah, you've got a few years on me. I took the 'elder' as a nod to the goth scene (which I was loosely a part of in my youth) as you can pick up the label of elder goth in your 20s.

      I've recently bought an Arduino Duemilanove (as in just received it over the weekend) because I wanted to play with some analog input stuff, and didn't really want to mess with designing an ADC for my Teensy just yet. Maybe later. Haven't had a chance to do much with it, though I did mess around with the EMF detector that was featured in the Make blog. Was a little odd to learn that my bedroom was so heavily flooded, maybe I should do something about that.

      I have learned a lot from the Arduino community, and I'm sure I will continue to. Even if I'd stuck 100% with the Teensy, they are based off the same family of AVR, so not a lot of difference for high level stuff. I've seen the RBBB, and it's interesting, actually when I saw that it got me thinking about actually building an AVR directly into a project. I know the whole point of the Arduino is rapid prototyping and eventually doing just that, but that was the moment it clicked for me.

      Thanks for the comment, and hope you stop by again. :)

      ReplyDelete
    3. But ... but ... The Teensy does indeed have analog inputs; even more of them than the Arduino courtesy of its higher pin count.

      ReplyDelete
    4. Not the Teensy v1 which is what was available at the time I wrote this. I haven't gotten a v2 yet.

      ReplyDelete