A simple Arduino sketch and Max patches for using an Arduino as a sensor interface. Includes code for driving multiplexers as well. The provides an easily extensible example for beginners and students to build projects around MaxMSP and Arduino.

February 5, 2011 | 8:57 am

Thank for this Andrew. It’s simple and easy to use. It did just what I needed.

April 18, 2011 | 6:32 am

Hi Andrew, I am trying to hook up four 4051 multiplexers to use with your Sensorbox but wanted to check that I have the below code right, to get all four muxes in via the Arduino A0, A1, A2, A3 analog channels. Is this correct? Many thanks in advance.

//select analog channels to multiplex
char is_muxPIN[6] = {1,1,1,1,0,0};//This is the only line of code I need to change;
//for A0, A1, A2, A3 analog pins hosting four muxes
char muxcount;//variable to store the number of multiplexed inputs

April 28, 2011 | 12:14 pm

Hi JasonD, that looks right to me. If you have trouble with it, let’s look at it in the forum.

December 14, 2011 | 1:42 am

Hi Andrew, I am trying to put all arduino mega’s analog input to max msp , is there a sensor box built for this need?
many thanks

June 13, 2012 | 1:20 pm

Hi Andrew

I have the same question as Carlo,

I am trying to use eight analog inputs on the Arduino mega, but I can only get a reading from six (not five, as I would excpect if the code and patch was made for the standard arduino board?)

I can´t seem to figure out how to change the patch or the arduino code to acoomidate more analog sensor inputs (except I suppose the spray object needs to be changed to [spray 8] ?

All the best

June 28, 2013 | 3:58 am

Hi Andrew,
This works great! I have used it with 24 light sensors interface.
I am actually thinking of turning it into kickstarter project and was wondering what license there is on this Arduino sketch and Max patch. How can I get in touch with you?

All best,

January 5, 2014 | 8:44 am

Hi Andrew,
thanks for the nice and simple patch – very useful to be able to get this quick progress :) – I am slightly confused though that I have sensors only on 2 pins on the arduino board (0 and 2) and yet all the analogue sliders are responding! :) – 2 or 3 sliders for each pin showing similar levels. any ideas ?

Are you working on more max patches for things like arduino ? (eg for output?) … also do you have a blog I can follow, to keep track with projects etc ? … ie projects in general

ps. is MUX simply an extended version of the other patch (to cater for more analogue inputs) … or is more going on ?

January 5, 2014 | 1:25 pm

Your other inputs are ‘floating’, ie. they have no reference to ground. Your seeing noise / crosstalk from the 2 connected inputs. Ignore it or pull inputs to ground to get stable 0’s.

January 6, 2014 | 12:39 pm

Yeah, what you are seeing is just floating unconnected pins. It’s harmless, but if it really bothers you, just tie those pins to ground and you won’t see them moving around. The MUX code is for use with one or more analog multiplex chips to multipy the inputs if you need lots of analog sensors. Depending on usage it might require a little customization in the arduino sketch.

January 8, 2014 | 3:48 am

Im trying to use this to just read the value coming from 3 analogue pins, but I cant seem to get anything through. Im a bit of a novice at this so I’m sure it’s something stupid. I have my arduino uno plugged in, with the standardfirmata example on. One thing i think it could be is on the umenu it doesnt have com3, 4 etc, but usbserial-a4001tfl. Is this right?
Any help would be massively appreciated

January 10, 2014 | 1:13 pm

There is an Arduino firmware sketch included. Load that on your board. This patch wasn’t intended to be used with Firmata.

March 2, 2015 | 7:39 am


I am using this sensor box patch but using it in max for live to control audio effects in ableton live for a performance at uni.

Can someone help me how to connect the pins and how get it to work in general in max for live for ableton live audio effects.


June 2, 2015 | 9:44 am


i would like to connect my own sketch to your SensorBox patch but i would like to know where i can do it because i see that the boxes in the low side of your sketch are outputs.


June 26, 2015 | 7:16 am

Hi there, I seem to be having an issue with the .pde. I haven’t altered the file in any way but it keeps giving me the following message regarding the first line:

expecting RBRACK, found ’12’

What should I do?

I’m using Mac OS X 10.10.3, the newest version of Processing and Arduino 1.0.5 if that helps any. I’m sorry if this is a stupid question, I’m very very new. So far nothing is reading in max.


Viewing 14 posts - 1 through 14 (of 14 total)

Explore More

Subscribe to the Cycling '74 Weekly Newsletter

Let us tell you about notable Max projects, obscure facts, and creative media artists of all kinds.

* indicates required