we are doing a max/msp project here at the interactive digital media, at ravensbourne college, uk, and decided to use arduino instead of the teleoboards they have here.
the project is a mixer, where we have 4 digital inputs (switches) and an analog one (weight sensor). we have to send this 5 informations to max so our patch can work the mixer.
at the london workshop, we've learnt how to send the serialport read to max, that's ok. the problem now is how to separate the informations. because we have a weight sensor constantly sending the information to max (byte values), we are not been able to tell when does a switch is turned on and off; it is sent together with the bytes of the weight sensor.
so, question: how to differentiate the serial information? how to tell which switch is on and off and still get the weight sensor information without scrambling everything?
the project is a mixer (we are using liquids to control sounds, it is
quite nice), where we have 4 digital inputs (switches) and an analog
one (weight sensor). we have to send this 5 informations to max so
our patch can work the mixer.
The best thing to do in this case is to send all formated somehow. I always recommend to do it making the board send a character to identify the sensor, and a value following, like:
this allows you to have different latencies for the different sensors
The way of reading this in MAX is a different story. You will have to either convert the patch we made for PureData (look at the www.arduino.ws website for the latest version) or to wait for a couple of days until I get an update from Greg at SFU in Vancouver, who is revising this very same patch for MAX/MSP.
so, question: how to differentiate the serial information? how to
tell which switch is on and off and still get the weight sensor
information without scrambling everything? I imagine we have to
configure the digitalread inside max, is that it?
The way to differenciate the different sensors is using the character in the front, that allows you to distinguish between different numeric inputs to the MAX patch.
i experienced some glitches (value will jump to zero) while constantly reading the serial data with serial object in max/msp??! do you have any clue? and which metro-time do you use for banging the serial object?
meanwhile, i downloaded the code-sniplet by David Cuartielles, but i couldnt open it, neiter as text, nor as patch? does it contain errors? i´m using max 4.5.4?
I got it to work. just delete the extension and drag it to max msp.
about the jumpy values, yeah I get that as well, I've posted another topic about it but with no success. But do you get that only when reading from max?
in your Arduino program, make sure you put a delay between printing the integers of your sensor.
So you would you have
printByte ('A');
printInteger (sensor1);
printByte (10);
printByte(13);
delay (20);
printByte ('B');
.......
The delay function is so Max, (as well asd Pure Data) can process the information. You might want to experiment with the delay (value) to find the duration that is fast but not too fast.
Hi there,
anyone tried to do this with processing? Benoit has been helping out but I'm still not having that much luck.
I'm basically usingthis code (slightly altered ):
to read from two ultrasounds on pins 6 and 7 on the i/o.
I have tried formatting the messages as discussed above, i.e:
serialWrite ('A');
printInteger (sensor1);
serialWrite (10);
delay (20);
serialWrite ('B');
printInteger (sensor2);
... and so on.
I can see that the data from both sensors is getting through to processing, yet one is domminant, the other only appears in processing every 8th - 10th line.
any ideas or do you think this is this more of a processing question?
(i hope) this is the relevant processing code:
if(serial!=10) {
buf += char(serial);
} else {
//extract the value from the string 'buf'
buf = buf.substring(1,buf.length());
//cast the value to an integer
value1 = int(buf);
buf="";
}