简体   繁体   中英

Arduino2max digital pin communication to max using an Arduino mega 2560

Im working on connecting an Arduino Mega 2560 into max msp, I have adapted the Arduino2max arduino code and max patch.

I have adapted the max patch and succeeded with all 16 analog inputs from arduino into max but cannot get any digital pins over number 13 into max msp. I was wondering if anyone had had any sucsess with this?

Any help and comments would be greatly appreciated!

Many thanks

Joe

here is the arduino code adapted from Arduino2max v.5 which can be found here http://www.arduino.cc/playground/Interfacing/MaxMSP

int x = 0;              
int ledpin = 13;

void setup ()
{
// 115200 is the default Arduino Bluetooth speed
Serial.begin(115200);
///startup blink
digitalWrite(13,HIGH);              
delay(600);
digitalWrite(13,LOW);
pinMode(13,INPUT);
}



void loop()
{ 
// Check serial buffer for characters
if (Serial.available() > 0){  
if (1){     //Serial.read() == 'r') { // If an 'r' is received then read the pins 
// Read and send analog pins 0-15
for (int pin= 0; pin<=15; pin++)
{ 
 x = analogRead(pin);
 sendValue (x);
}

// Read and send digital pins 2-53
for (int pin= 2; pin<=53; pin++)

{         
 x = digitalRead(pin);
 sendValue (x);
}

 // Send a carriage return to mark end of pin data.
    Serial.println(); 
 // add a delay to prevent crashing/overloading of the serial port
delay (5);                        
 }
}
}
// function to send the pin value followed by a "space".
void sendValue (int x){ 
 Serial.print(x);
 Serial.print(32, BYTE);
 }

Thanks again!

I suggest you to use the OSC Protocol to communicate between the Arduino Mega and Max. I use the library ardosc. There is no documentation on it but its not really hard to use it and it is a good library.

If you cannot use it do not hesitate to ask me some explanations

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM