I couldn’t let this pass by without announcing it here, it’s just a simple tool to interface Max with Arduino back and forth.
Tag: serial
New Basic Arduino Serial Communication
This is an updated example of basic serial communication between Arduinos, the old example can be found here.
Sender code:
[Arduino]
// SENDER
int b1 = 7;
int b2 = 8;
void setup()
{
Serial.begin(9600);
pinMode(b1, INPUT);
pinMode(b2, INPUT);
digitalWrite(b1, HIGH);
digitalWrite(b2, HIGH);
}
void loop()
{
byte val1 = (byte)digitalRead(b1);
byte val2 = (byte)digitalRead(b2);
Serial.write(‘a’); //SYNC char
Serial.write(val1);
Serial.write(‘b’); //SYNC char
Serial.write(val2);
delay(50);
}
[/Arduino]
Receiver Code:
// RECIEVER
byte led1;
byte led2;
void setup() {
Serial.begin(9600);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
delay(1000);
}
void loop() {
if(Serial.available() > 0)
{
char inChar = Serial.read();
while(Serial.available()<=0);
if (inChar == ‘a’)
{
led1 = Serial.read();
}
if (inChar == ‘b’)
{
led2 = Serial.read();
}
}
digitalWrite(9, led1);
digitalWrite(8, led2);
delay(10);
}
Max + Arduino + Industrial Motor
At Artica, we had a request to link MAXMSP to an industrial motor for an artistic installation witch we will speak about at another time.
This motor is a true beast, and since we have never worked with such a thing we decided to ask for help to our electronics guru David Palma.
David developed an electronic circuit to simulate a PWM analog output from 0 to 10v (originally it gives 0 to 5v), and another circuit to switch motors direction, both circuits were assembled on a shield and connected to the motor controller.
The first circuit is a transducer:
And this is the switch circuit that tell to the motor controller wich direction the motor will spin:
Then he builded an Arduino shield:
And the final part was the Max patch that send the direction states and the PWM values to the Arduino:
And this is the result:
MAXMSP – ARDUINO – INDUSTRIAL MOTOR from artica on Vimeo.
And last but not the least all the source codes can be downloaded here