Old code for Uno needs updating

I need to upload code for an Uno that is using 6 digital (jack inputs) and 4 analog (jack inputs) to send controller information to Max.

The code that worked years ago seems to be outdated.

Could someone help me with this?


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

  • This version: .4, October 2007

//#incude <SimpleMessageSystem.h>

int x = 0; // a place to hold pin values
int ledpin = 13;
int abuttonPin = 2; // button 1
int bbuttonPin = 3; // button 2
int cbuttonPin = 4; // button 3
int dbuttonPin = 5; // button 4
int ebuttonPin = 6; // button 5
int fbuttonPin = 7; // button 6
int gbuttonPin = 8; // button 7
int hbuttonPin = 9; // button 8
int ibuttonPin = 10; // button 9
int jbuttonPin = 11; // button 10
int kbuttonPin = 12; // button 11
int lbuttonPin = 13; // button 12

void setup()
Serial.begin(115200); // 115200 is the default Arduino Bluetooth speed
digitalWrite(13,HIGH); ///startup blink
pinMode(abuttonPin, INPUT); // set pin2 to input
digitalWrite(abuttonPin, HIGH); // turn on pullup resistors
pinMode(bbuttonPin, INPUT); // set pin3 to input
digitalWrite(bbuttonPin, HIGH); // turn on pullup resistors
pinMode(cbuttonPin, INPUT); // set pin4 to input
digitalWrite(cbuttonPin, HIGH); // turn on pullup resistors
pinMode(dbuttonPin, INPUT); // set pin5 to input
digitalWrite(dbuttonPin, HIGH); // turn on pullup resistors
pinMode(ebuttonPin, INPUT); // set pin6 to input
digitalWrite(ebuttonPin, HIGH); // turn on pullup resistors
pinMode(fbuttonPin, INPUT); // set pin7 to input
digitalWrite(fbuttonPin, HIGH); // turn on pullup resistors
pinMode(gbuttonPin, INPUT); // set pin8 to input
digitalWrite(gbuttonPin, HIGH); // turn on pullup resistors
pinMode(hbuttonPin, INPUT); // set pin9 to input
digitalWrite(hbuttonPin, HIGH); // turn on pullup resistors
pinMode(ibuttonPin, INPUT); // set pin10 to input
digitalWrite(ibuttonPin, HIGH); // turn on pullup resistors
pinMode(jbuttonPin, INPUT); // set pin11 to input
digitalWrite(jbuttonPin, HIGH); // turn on pullup resistors
pinMode(kbuttonPin, INPUT); // set pin12 to input
digitalWrite(kbuttonPin, HIGH); // turn on pullup resistors
pinMode(lbuttonPin, INPUT); // set pin13 to input
digitalWrite(lbuttonPin, HIGH); // turn on pullup resistors

void loop()

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

if (Serial.read() == ‘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”.

What “seems” to be the problem?

Why do you assume that “old code” rotted?

I changed the last line of the code to: Serial.write(32); }

Since I got an error message saying that the original code Serial.print(32, BYTE);

is no longer supported.

Max is not receiving the data from the Arduino. I'm wondering if I need to do more updates to get Max to read it.


void sendValue (int x){              // function to send the pin value followed by a "space". 
 Serial.print(' '); 

who's Max?



Thanks for your help. I need to do some deeper trouble shooting in the soldering and pin connections before I can judge where the final issue lies.


Thanks for helping out with the last line of code. I attended to a soldering issue and the Arduino, the code and the controller device are all working fine.