I am using the arduino diecimila to turn an LED on and off. To do this im using a very simple max/msp patch thats sends a value of 154 into the serial object to turn the LED on and 0 to turn the LED off.
This works fine with this sketch loaded on to the arduino. int LEDPin = 9;
void setup()
{
// begin the serial communication
Serial.begin(9600);
pinMode(LEDPin, OUTPUT);
}
void loop()
{
byte val;
// check if data has been sent from the computer
if (Serial.available()) {
// read the most recent byte (which will be from 0 to 255)
val = Serial.read();
// set the LED on or off
analogWrite(LEDPin, val);
}
}
this works absolutely fine but i want to be able to control more than one pin out from max, so i can control multiple LEDs independently. how do i go about this? how can i get the serial object to transmit separate data to each pin out on the Arduino?
sorry if this is a very simple question, thanks