need help making Max/MSP talk to Arduino w/TinkerIt! DMX Shield
preface: i have NO idea what i'm doing with Arduino yet. have done just enough research to be dangerous but based on said research it seemed like it would be more or less plug-and-play to do what i want to do, but that seems to be far from the truth.
i ultimately want to be able to use touchOSC to control a small lighting rig via Max/MSP (i usually run Ableton during my live sets so M4L seems like an obvious choice to make all this happen). i have an Arduino Uno equipped with a TinkerIt! DMX Shield and have been experimenting with the DMX Master library (for Arduino) and have thus far only been successful in writing small chunks of Arduino code to control a single light (will experiment with more lights once i get basic functionality down). the Arduino code i wrote to turn the light red at max intensity looks like this:
#include
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
DmxMaster.write(1,255);
DmxMaster.write(2,255);
}
works like a charm. the problem is, i cannot for the life of me figure out how to use Max to send data like this to the Arduino in real time. i've tried Maxuino, but it seems to only be ready to accept values sent to clearly specified analog and digital outputs; whenever i try to send it messages like "DmxMaster.write(1, 255)" it says something about not being able to figure out what i'm trying to do.
i'm certain the problem is that the Maxuino javascript interpreter is not prepared to receive/translate DmxMaster messages, but because the DMX shield i'm using has almost no documentation whatsoever and i have absolutely no experience with Arduino at all (except for the first few tutorials on the Arduino site and the DMX script i shared above) i have no idea how to go about figuring out how the DMX shield hardware works (what pins receive what values, etc.) in order to modify the Maxuino javascript interpreter for my purposes.
in short, need to figure out how to send messages of syntax "DmxMaster.write(x, y)" to Arduino in real-time from Max/MSP via the serial port. does anyone know of a way that i can make that happen?
many thanks in advance to any that contribute in any way to solving this issue.
Hi Chris,
the serial link on the Arduino side reads one byte at a time ( that means a number 0-255). I was very successful making a "protocol" of sorts on the Arduino end by sending multiple bytes (which Arduino reads one at a time) and building up a command and control sequence from the values in the bytes. So basically you could send the x and y values of your DmxMaster.write command and then execute the command on the Arduino end, provided the execute byte was included in your message. I am suggesting a sequenced control method on the Arduino end. I used a 5 byte sequence, the first byte was always the command byte that starts the sequence (indicated by the value in the command byte) and then I used the following 4 bytes to populate the variables I wanted to build on the Arduino side. I was controlling a stepper motor with Arduino so my command byte was 10(start) or 30(stop) followed by 4 bytes (a modulo 255 operation of the movement time in seconds), a number of half lengths(the motor is driving a trolley that moved back and forth on a rail, always starting and stopping in the center), the configuration (mockup or site installation - mockup was my test mockup at home and site installation was the gallery) and the starting direction byte (1=forward, 2=backwards). It worked great. I'm sure you could set up something similar.
thanks for the advice! i'll look into how to execute such a thing. as mentioned earlier, i have almost no experience with programming outside of max, but this should at least send me in the right direction.