Black Lives Matter - Action and Equality. ... Adafruit joins the Stop Hate for Profit campaign.
0

ARDUINO MEGA WITH MAX MSP HELP !!!!
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

ARDUINO MEGA WITH MAX MSP HELP !!!!

by azahn123 on Mon Oct 04, 2010 5:30 pm

Hi... I bought an arduino mega ... I am now trying to get this to work with MAX MSP... I am sucessful getting this to work ... BUT only the first analog pins up to 5 are working .. PLEASE HELP! I am using this for my senior thesis at The University of the Arts here in Philly.... This is the code I am using... But when I change the pins to work for all they still only work with 0- 5 ?! Below I have made BOLD the part that I change ... but it still only functions with 0-5 : (


/*
* 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 tof.danslchamp.org
*
*/


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
delay(600);
digitalWrite(13,LOW);
pinMode(13,INPUT);
}



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".
Serial.print(x);
Serial.print(32, BYTE);
}
User avatar
azahn123
 
Posts: 6
Joined: Tue Dec 08, 2009 3:29 am
Location: student

Re: ARDUINO MEGA WITH MAX MSP HELP !!!!

by cstratton on Mon Oct 04, 2010 7:14 pm

Do you mean that it only does the five, or that the ones beyond that are giving invalid readings?

Are you sure you managed to download the new program? Sometimes it's useful to have your program print a version number that you increment each build just to eliminate the possibility that the programming failed and you are still running an old version.

bugs can be sneaky, so set lots of traps for them - put debug output everywhere, then comment it out once its working.

cstratton
 
Posts: 294
Joined: Wed Sep 29, 2010 3:52 pm

Re: ARDUINO MEGA WITH MAX MSP HELP !!!!

by azahn123 on Tue Oct 05, 2010 3:24 am

No I downloaded this code along with a patch for Max... Its called "Arduino2MAX_V.4". This is the link: http://www.arduino.cc/playground/Interfacing/MaxMSP
I figured I could just edit the arduino code and get it working but when I try to use the Mega with Max ONLY the 0 - 5 analog inputs are working (as far as analog in goes). Do I have to edit these other files that came with it ? They are .co files that have a bunch of scrambled letters and number. I also tried to edit the Max patch but dont really know what I am doing !?
User avatar
azahn123
 
Posts: 6
Joined: Tue Dec 08, 2009 3:29 am
Location: student

Re: ARDUINO MEGA WITH MAX MSP HELP !!!!

by chatham on Tue Oct 05, 2010 3:38 am

I think your bold stuff got left out, or at least I'm not seeing it...

What sort of outputs are you seeing? Could you show us a brief sample of what the Arduino Serial Monitor is showing for both sets of code you're trying (the one that works, and the one that's not working, with the Digital pins)? Also, when doing that/debugging, you might want to take the part where
Code: Select all | TOGGLE FULL SIZE
if (Serial.read() == 'r') { // If an 'r' is received then read the pins

and change it to
Code: Select all | TOGGLE FULL SIZE
if (1){     //Serial.read() == 'r') { // If an 'r' is received then read the pins

so that you don't have to send an 'r' to the Arduino when you want data. Make debugging as simple as you can.
OpenChord.org - Open Source kits to let you play Guitar Hero with a real guitar, or build your own Wii/PS3/USB controllers.

chatham
 
Posts: 144
Joined: Thu Feb 04, 2010 2:30 am

Re: ARDUINO MEGA WITH MAX MSP HELP !!!!

by azahn123 on Tue Oct 05, 2010 3:51 am

Ok I am trying your suggestion, but I can't see anything in the serial monitor even when I turn a knob connected to analog pin 5 (which DOES work with MAX) PS I am using max 5.
User avatar
azahn123
 
Posts: 6
Joined: Tue Dec 08, 2009 3:29 am
Location: student

Re: ARDUINO MEGA WITH MAX MSP HELP !!!!

by azahn123 on Tue Oct 05, 2010 4:49 am

Ok so I am getting the analog pins beyond # 5 to work with a pot... But still not in MAX ... What is the deal >???
User avatar
azahn123
 
Posts: 6
Joined: Tue Dec 08, 2009 3:29 am
Location: student

Re: ARDUINO MEGA WITH MAX MSP HELP !!!!

by azahn123 on Tue Oct 05, 2010 4:30 pm

SUCESS !!!! I edited the Max patch within the other patch and everything is working !!! Thanks for your help....
User avatar
azahn123
 
Posts: 6
Joined: Tue Dec 08, 2009 3:29 am
Location: student

Please be positive and constructive with your questions and comments.