Arduino SensorBox Firmware

SensorBox

SensorBox

While I’m a sort of reluctant Arduino user, I often use them for classes and workshops that I teach because they’re pretty easy to get started with and cheap. Lately, I’ve been a bit disillusioned though with the firmware examples available for using the Arduino with MaxMSP, and wanted to remedy that. I found that most of my students just wanted an easy way to connect sensors and switches to an Arduino and have that show up in Max. While the Firmata firmware is very well designed and offers a lot of features, I have been frustrated too many times by not being able to fix bugs in the code myself. Also, the reliance on the “arduino” abstraction has led to all sorts of problems with students who haven’t learned about file dependencies and search paths in Max.
My solution was to write a very simple and relatively efficient firmware called SensorBox that just gets the input from all the pins on the Arduino and sends it over serial to a Max patch. The communication protocol is hardly innovative, but it should give a good example of ways to efficiently transmit data over serial. The goal was to make everything simple and readable, and to avoid any voodoo, so that others can alter and fix the code as they please.
Also, since many real-world projects require more than 6 analog inputs, I wrote an alternate version of the SensorBox firmware called SensorBoxMux that allows you to configure any analog pin(s) for multiplexed input with an inexpensive 4051 8×1 IC. This offers the potential for up to 96 analog inputs on Arduino!

Download SensorBox firmware and Max 5 patches.

9 Responses to “Arduino SensorBox Firmware”

  1. scott Says:

    Hey Andrew, just curious what you think about the serial communication examples included in the Arduino software. have those been of use to your students?

    I’m not a fan of Firmata either, too much of a black box, and it doesn’t require students to think about the process of information moving in either direction.

    Looking forward to trying the Sensorbox to see what it offers.

  2. Andrew Says:

    The serial examples that come with the IDE are good, but don’t really offer a way to dive right in. For my specific purposes, I really need examples that work right out of the box, but are legible for the daring ones who care to dive into the firmware.

  3. digitalColeman Says:

    Andrew,
    great tool, thanks for making it available. Im the guy doing the maxuino (firmata -> max) upkeep, and I am also always looking for next steps. I like how firmata can get my students going instantly, but for those that need more or less access, tools like this uncrack it quite well. My question to you as a fellow teacher is how can we more effectively share these tools we are constantly making?

  4. Andrew Says:

    @digitalColeman Great work with that. A lot of people use that patch and Firmata and it keeps getting better. Your question is a good one. Teaching materials are an interesting form of I.P., and can sometimes be fairly guarded secrets, especially in electronic media. I once heard of a professor suing another professor for plagiarizing his syllabus.

  5. Tom Igoe Says:

    Andrew, have you looked at the latest batch of serial examples for Arduino? We had a lot of requests for Max patches with them, so we updated them with Max 5 examples. Let me know what’s not working about them, what you might change, etc. e.g. http://arduino.cc/en/Tutorial/Graph and others, the Max examples are at the bottom of the page.

  6. Andrew Says:

    Hi Tom, I should perhaps elaborate on my comment above. I really appreciate the serial examples that are built into the Arduino IDE, and I leaned on them heavily in putting this together. My main purpose in designing this is to create something of a middle ground between the simplicity of your examples and the obfuscation of the Firmata examples. I also wanted to provide an example of multiplexing inputs since several of my students are working on projects that require more analog inputs. In my classes, the arduino is typically introduced as one of many possible solutions to get information into Max, so the first few exercises involve plugging things into pins and connecting that to something meaningful. For that, I need a plug-and-play firmware that everyone can load up and start going. After that people tend to go off in their own directions. Some of them want to work a lot on hardware, some focus more on media, whatever. For awhile I had been using Firmata to get them started, and then if they wanted to extend it, they would have to either start from scratch with the serial examples or learn how to access the hidden treasures of Firmata. For this purpose, I think this example works pretty well. I post it here in hopes someone else might find it useful.

  7. Tom Igoe Says:

    Ahh, I see. In that case, there are a couple things that might be worth doing style-wise, so the students who want to code their own hardware can understand the code easier — more verbose variable names, comments explaining the shift operators (or use of bitWrite() and bitRead() instead), . Are your students beginning programmers, intermediate, or advanced?

    I like the idea of a plug & play firmware that’s also easy to understand, and this is a nice start on that. Good stuff! I’ll look at incorporating some of these ideas in a new example next time I’m working on those, if it’s okay with you. If you see other things we can do with the Arduino examples to improve them, let me know.

  8. Andrew Says:

    Hi Tom, thanks for the valuable feedback! All great points, and I will look at ways to work that in when I’m in the mood to revise the firmware. Feel free to borrow ideas and code as you please.

  9. max abeles Says:

    great stuff here

Leave a Reply