Need Help: Accelerometer With MAX/MSP Patch

I am trying to get an accelerometer to work with the MAX / MSP Patch. The accelerometer chip has sparkfun written on it but no data sheet was given with it. I am pretty sure it was one of the 3 versions this .

I am trying to get a accelerometer to work with the MAX / MSP Patch and sketch programming provided at . I wired the X, Y , Z (axis) each to a separate analog pin. The gnd on the Arduino is connected to the gnd of the accelerometer. The voltage on the accelerometer is connected to the 3V on the Arduino.

When I start the MAX/MSP patch, it is giving random numbers on the MAX number boxes for the analog pins on the Arduino that are connected to the X,Y,Z (axis). They constantly change as if noise or something is hitting the pins. However, as soon as I move the Accelerometer, the numbers freeze. No more data comes into the MAX number boxes that are interfaced with the pins. If I move the accelerometer again after the it freezes, nothing happens. The numbers that were in the number box of the MAX patch that are frozen, stay there. Does anyone have any suggestions of what is happening and how I can solve this? Has anyone had the same problem?

Has anyone successfully used an accelerometer with the MAX/MSP patch & sketch at ? If so, can you tell me how you did it and what accelerometer you used? Thanks for any suggestions and help.

Below is a copy of the Sketch that is working with the MAX / MSP patch.


  • Arduino2Max
  • Send pin values from Arduino to MAX/MSP
  • Arduino2Max.pde

  • This version: .4, October 2007

  • Copyleft: use as you like
  • by Daniel Jolliffe
  • Based on a sketch and patch by Thomas Ouellet Fredericks


int x = 0; // a place to hold pin values
int ledpin = 13;

void setup()
Serial.begin(115200); // 115200 is the default Arduino Bluetooth speed
digitalWrite(13,HIGH); ///startup blink

void loop()

if (Serial.available() > 0){ // Check serial buffer for characters

if ( == ‘r’) { // If an ‘r’ is received then read the pins

for (int pin= 0; pin<=5; pin++){ // Read and send analog pins 0-5
x = analogRead(pin);
sendValue (x);

for (int pin= 2; pin<=13; pin++){ // Read and send digital pins 2-13
x = digitalRead(pin);
sendValue (x);

Serial.println(); // Send a carriage returnt to mark end of pin data.
delay (5); // add a delay to prevent crashing/overloading of the serial port



void sendValue (int x){ // function to send the pin value followed by a “space”.
Serial.print(32, BYTE);