dimming 3 leds with max

alright gang, ive got 3 leds (red, green, blue) to make a full spectrum of colour, im trying to control each led individually though max, how do i do this exactly? is it the arduino software or do i need to make some sort of list from max/map to the serial?

I don't know MAX very well, but to make MAX control Arduino and then Arduino control the LED's you will need to send three values from MAX over the serial line to Arduino Each value should be in the 0 - 255 range.

Then on the Arduino board you should connect each LED to an PWM pin and have arduino read the values from MAX, and then set the intensity of each LED with that value with the AnalogWrite command.

Check here http://www.arduino.cc/en/Tutorial/DimmingLEDs

yeah ive got that without a hitch, its when i introduce another number it gets confused. just starts flickering and only effecting the same led not the second. i guess its just reading the numbers again and doesnt seem to know where to put them. tell me if that doesnt make sense

Could you post the Arduino code ?

int ledPina = 11; int ledPinb = 10; int ledPinc = 9;

byte vala; byte valb; byte valc;

void setup() { // begin the serial communication Serial.begin(9600);

pinMode(ledPina, OUTPUT); pinMode(ledPinb, OUTPUT); pinMode(ledPinc, OUTPUT); }

void loop() {

if (Serial.available()) { vala = Serial.read(); valb = Serial.read(); valc = Serial.read(); analogWrite(ledPina, vala); analogWrite(ledPinb, valb); analogWrite(ledPinc, valc);

}

}

max v2;

N vpatcher 273 125 1139 813;

P origin 52 219;

P window setfont "Sans Serif" 9.;

P window linecount 1;

P newex 673 665 63 196617 print status;

P number 652 483 32 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;

P number 619 483 31 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;

P number 587 483 31 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;

P newex 601 659 32 196617 print;

P newex 596 552 52 196617 pak 0 0 0;

B color 5;

P user uslider 588 329 18 128 255 1 0 0;

P user uslider 627 323 18 128 255 1 0 0;

P comment 585 282 32 196617 Red;

P comment 623 281 32 196617 Green;

P number 660 298 32 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;

P number 627 298 31 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;

P number 595 298 31 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;

P newex 595 252 75 196617 unpack 0 0 0;

P user uslider 660 324 18 128 255 1 0 0;

P newex 625 627 71 196617 serial a 9600;

P number 383 116 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;

P number 345 115 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;

P newex 331 157 52 196617 pak 0 0 0;

P user swatch 467 76 190 90;

P number 305 115 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;

P comment 658 280 32 196617 Blue;

P connect 1 0 3 0;

P connect 4 0 3 1;

P connect 5 0 3 2;

P connect 3 0 2 0;

P connect 15 0 18 0;

P connect 9 0 15 0;

P connect 2 0 8 0;

P connect 8 0 9 0;

P connect 18 0 16 0;

P connect 6 0 17 0;

P connect 19 0 16 1;

P connect 14 0 19 0;

P connect 16 0 6 0;

P fasten 8 1 10 0 632 272 632 272;

P connect 10 0 14 0;

P connect 20 0 16 2;

P connect 7 0 20 0;

P fasten 8 2 11 0 664 272 665 272;

P connect 11 0 7 0;

P connect 6 1 21 0;

P pop;

max and the arduino

int ledPina = 11; int ledPinb = 10; int ledPinc = 9;

int vala; int valb; int valc;

void setup() { // begin the serial communication Serial.begin(9600);

pinMode(ledPina, OUTPUT); pinMode(ledPinb, OUTPUT); pinMode(ledPinc, OUTPUT); }

void loop() {

if (Serial.available()) { vala = Serial.read(); valb = Serial.read(); valc = Serial.read(); Serial.print(vala); Serial.print(valb); Serial.print(valc);

analogWrite(ledPina, vala); analogWrite(ledPinb, valb); analogWrite(ledPinc, valc);

}

}

seems to work better when i did that

no one?? can it actually be done?

http://www.youtube.com/watch?v=dvaWK0QuLqQ this guys seems to have got it

The Arduino code looks ok to me. Unfurtunately i don’t know much about Max so i can’t really see if it is ok or not.

Which par of the Max code is sending data over the srial line, what are the values beeing sent ?

i got it!

hey could you possibly post ur arduino and max code? is it possible to use usb with that?