LaurAwesome Searching for the perfect screwdriver…laura@laurawesome.com

Blazing the trail of Awesome!

As we started our trek we had many unknown foes, the arduino, max msp, audio inputs. We tackled an easy an output

int ledPin_01=2;
int ledPin_02=3;
int ledPin_03=4;
int ledPin_04=5;
void setup()
{ pinMode(ledPin_01, OUTPUT);
pinMode(ledPin_02, OUTPUT);
pinMode(ledPin_03, OUTPUT);
pinMode(ledPin_04, OUTPUT); }

void loop() { digitalWrite(ledPin_01, HIGH);
delay(500); digitalWrite(ledPin_01, LOW);
delay(500); digitalWrite(ledPin_02, HIGH);
delay(500); digitalWrite(ledPin_02, LOW);
delay(500); digitalWrite(ledPin_03, HIGH);
delay(500); digitalWrite(ledPin_03, LOW);
delay(500); digitalWrite(ledPin_04, HIGH);
delay(500); digitalWrite(ledPin_04, LOW); delay(500); }

As we realized the true task ahead was really much greater. The input we wanted had to be processed through another software proving to be in a cunning disguise of cute gui buttons. But nothing is to great for our heroes.
First we found a patch for the arduino to send an input to MAX|MSP
#include

/*
—- SimpleMessageSystem Example 1 —-
Control Arduino board functions with the following messages:

r a -> read analog pins
r d -> read digital pins
w d [pin] [value] -> write digital pin
w a [pin] [value] -> write analog pin

Base: Thomas Ouellet Fredericks
Additions: Alexandre Quessy

*/

// Include de SimpleMessageSystem library
// REMOVE THE FOLLOWING LINE IF USING WIRING

void setup()
{

// The following command initiates the serial port at 9600 baud. Please note this is VERY SLOW!!!!!!
// I suggest you use higher speeds in your own code. You can go up to 115200 with the USB version, that’s 12x faster
Serial.begin(115200); //Baud set at 9600 for compatibility, CHANGE!

}

void loop()
{

if (messageBuild() > 0) { // Checks to see if the message is complete and erases any previous messages
switch (messageGetChar()) { // Gets the first word as a character
case ‘r’: // Read pins (analog or digital)
readpins(); // Call the readpins function
break; // Break from the switch
case ‘w’: // Write pin
writepin(); // Call the writepin function
}

}

}

void readpins(){ // Read pins (analog or digital)

switch (messageGetChar()) { // Gets the next word as a character

case ‘d’: // READ digital pins

messageSendChar(‘d’); // Echo what is being read
for (char i=2;i<14;i++) {
messageSendInt(digitalRead(i)); // Read pins 2 to 13
}
messageEnd(); // Terminate the message being sent
break; // Break from the switch

case ‘a’: // READ analog pins

messageSendChar(‘a’); // Echo what is being read
for (char i=0;i<6;i++) {
messageSendInt(analogRead(i)); // Read pins 0 to 5
}
messageEnd(); // Terminate the message being sent

}

}

void writepin() { // Write pin

int pin;
int state;

switch (messageGetChar()) { // Gets the next word as a character

case ‘a’ : // WRITE an analog pin

pin = messageGetInt(); // Gets the next word as an integer
state = messageGetInt(); // Gets the next word as an integer
pinMode(pin, OUTPUT); //Sets the state of the pin to an output
analogWrite(pin, state); //Sets the PWM of the pin
break; // Break from the switch

// WRITE a digital pin
case ‘d’ :

pin = messageGetInt(); // Gets the next word as an integer
state = messageGetInt(); // Gets the next word as an integer
pinMode(pin,OUTPUT); //Sets the state of the pin to an output
digitalWrite(pin,state); //Sets the state of the pin HIGH (1) or LOW (0)

}

}

Then we figured out how to read that input in MAX and start to manipulate an input.



Which we then took and made more little flashy lights.

_Laura and Jessica!

Reply