Forums > MaxMSP

Lighting an LED on an Arduino using Max

October 10, 2007 | 10:11 pm

Hey all,

I first would like to thank everyone for being so supportive of me and helping me out.

Now to the question:

I got my Arduino to load code, I ran Max2Arduino code in the Arduino and opened up the Max patch. I’ve changed the port to "b" for usb. I got all the analog pins to stream numbers and the digital pins are banging [haha] in the patch.

I plug an led into ground and any of the digital pins and the LED will not blink. How do I make the LED blink on an Arduino board using Max?????

~nks


October 10, 2007 | 10:24 pm

I’m definitely not an expert… I’ve only used the MidiTron (never the arduino). But, on that device you connect the LED to the terminal and 5v power source (NOT the ground). I would assume its the same on the Arduino (circuits are circuits, right?)

Hope that helps
/dan

Quote: snites5000@gmail.com wrote on Wed, 10 October 2007 16:11
—————————————————-
> Hey all,
>
> I first would like to thank everyone for being so supportive of me and helping me out.
>
> Now to the question:
>
> I got my Arduino to load code, I ran Max2Arduino code in the Arduino and opened up the Max patch. I’ve changed the port to "b" for usb. I got all the analog pins to stream numbers and the digital pins are banging [haha] in the patch.
>
> I plug an led into ground and any of the digital pins and the LED will not blink. How do I make the LED blink on an Arduino board using Max?????
>
> ~nks
—————————————————-


October 10, 2007 | 11:22 pm

Thanks for the response. Unfortunately…I tried that and it didn’t work.

~nks


October 10, 2007 | 11:35 pm

Got nothing then…

Sorry and good luck

Quote: snites5000@gmail.com wrote on Wed, 10 October 2007 17:22
—————————————————-
> Thanks for the response. Unfortunately…I tried that and it didn’t work.
>
> ~nks
—————————————————-


October 11, 2007 | 2:57 am

Be sure to only use digital 13 for direct connection of the LED (it has built-in resistor). I’ve heard the others will burn out LED’s as they are too high-current… maybe you have burnt some of yours out.

Other than that, just be sure the blink code is right… ?

I’m messing with Arduino and it’s been a struggle sometimes, but generally good. Got some good communication between Max and Arduino going, can control the rates and such of LEDs and lasers from the patch. And Arduino2Max is a blessing to take the work out of indexing the data out.

–CJ


October 11, 2007 | 5:28 am

hi

I wrote the Arduino2Max software.. crude as it is.

You can’t get the led to light up because… it is written to only read the pins, not to activate them!

Let’s say you want to change it to activate pins 7-13 as outputs.
Do this:
- remove the Arduino-side code that reads 7-13
- as an if then statement to look for a character or string sent by Max over the serial port, like
"w" for write. Inside that loop, write to the pins using digitalWrite statments.
- tell max to send W followed by pin state data.

Finally, if you do this, post the new code to the Arudino playground, so others can benefit!

Daniel


October 11, 2007 | 5:30 am

I should have written "add an if statement"


October 11, 2007 | 12:12 pm

may i recommend marius schebella’s maxduino?

http://www.parasitaere-kapazitaeten.net/max_msp/pduino_for_max

it will both light up and read.

On Oct 11, 2007, at 1:29 AM, terminalcity wrote:

>
> hi
>
> I wrote the Arduino2Max software.. crude as it is.
>
> You can;t get the led to light up because it is written to only
> read the pins, not to activate them!
>
> Let’s say you want to change it to activate pins 7-13 as outputs.
> Do this:
> – remove the Arduino-side code that reads 7-13
> – as an if then statement to look for a character or string sent by
> Max over the serial port, like
> "w" for write. Inside that loop, write to the pins using
> digitalWrite statments.
> – tell max to send W followed by pin state data.
>
> Finally, if you do this, post the new code to the Arudino
> playground, so others can benefit!
>
> Daniel
>


September 22, 2009 | 4:32 am

I don’t know how you’ve managed to get that working. I am using the Maxuino test patch and Firmata on the Arduino side. The LED plugged in to pin 13 doesn’t blink. I am so frustrated with this – I’ve tried everything I can think of and it just doesn’t work. Is there anything else I should be trying?


October 16, 2009 | 10:32 pm

uhm…
You might have inserted the LED the wrong way.
LED’s are diodes which only lead the electrones one way(from katode to anode).

if you look close, one side of the LED has a flat edge. the connector on that side goes to ground.

if you are planning on using this on the board you need to add a resistance in serial to the diode somewhere between the diode and 5v or gnd.

this resistance should be about 220 ohm(given that the diode needs about 20mA to operate). diodes have ca. 0.3v loss. dunno why.

OHM’s law say that :

U = I*R which gives

(5-0.3)v/20mA = R —> R = 220 ohm

basic electronics i know. for those who does’nt know, it might stop them from breaking something expensive.


October 18, 2009 | 12:17 pm

hi,

maybe this can halp you. the arduino code is not tested..

—–

char id; //max pak input 1( pak 0 1)
int data = 0; //max pak input data (pak 0 number)

void setup() {

Serial.begin(9600);

}

void loop()

{
while ((Serial.available() > 1)){

id = Serial.read();
data = Serial.read();

if (id == 2){

if (data != 0){
digitalWrite(12, HIGH);
}
else{
digitalWrite(12, LOW);
}

}
if (id == 3){

if (data != 0){
digitalWrite(13, HIGH);
}
else{
digitalWrite(13, LOW);
}
}

}

}

}

——

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P comment 314 242 132 196617 this is your id number>>>>;
#P toggle 476 212 15 0;
#P newex 443 239 43 196617 pak 2 0;
#P comment 487 243 132 196617 < <<< this is your data input;
#P toggle 266 115 15 0;
#P newex 238 139 43 196617 pak 2 0;
#P comment 284 114 100 196617 enable;
#P toggle 86 135 15 0;
#P newex 86 104 44 196617 loadbang;
#P newex 86 160 46 196617 metro 1;
#P toggle 184 78 15 0;
#P newex 156 102 38 196617 pak 3 0;
#P newex 129 201 98 196617 serial a 9600 8 1 0;
#P comment 202 77 100 196617 directions;
#P connect 12 0 11 1;
#P connect 9 0 8 1;
#P connect 3 0 2 1;
#P connect 8 0 1 0;
#P connect 2 0 1 0;
#P connect 4 0 1 0;
#P connect 6 0 4 0;
#P connect 5 0 6 0;
#P window clipboard copycount 14;


October 23, 2009 | 9:48 am

i’ve got some issues with this as well. I am trying to send integers to the arduino(duemilanove) from max. The arduino is also supposed to send the integers wirelessly using a easy radio transceiver.

i dont know if i receive the right values from max.

these are my programs so far(arduino and max(not the program to receive wirelessly, only the one to receive from max and send it on.)

thanks for all help.

PS: much of this is code which i have used from other programs i have found on forums aso.

max code(max 5):

{
"boxes" : [ {
"box" : {
"maxclass" : "message",
"text" : "2",
"bgcolor2" : [ 0.867, 0.867, 0.867, 1.0 ],
"numinlets" : 2,
"fontname" : "Arial",
"gradient" : 0,
"numoutlets" : 1,
"id" : "obj-11",
"textcolor" : [ 0.0, 0.0, 0.0, 1.0 ],
"presentation_rect" : [ 0.0, 0.0, 0.0, 0.0 ],
"background" : 0,
"fontface" : 0,
"outlettype" : [ "" ],
"bgcolor" : [ 0.867, 0.867, 0.867, 1.0 ],
"fontsize" : 10.0,
"ignoreclick" : 0,
"patching_rect" : [ 719.0, 436.0, 32.5, 16.0 ],
"presentation" : 0,
"hidden" : 0
}

}
, {
"box" : {
"maxclass" : "message",
"text" : "1",
"bgcolor2" : [ 0.867, 0.867, 0.867, 1.0 ],
"numinlets" : 2,
"fontname" : "Arial",
"gradient" : 0,
"numoutlets" : 1,
"id" : "obj-10",
"textcolor" : [ 0.0, 0.0, 0.0, 1.0 ],
"presentation_rect" : [ 0.0, 0.0, 0.0, 0.0 ],
"background" : 0,
"fontface" : 0,
"outlettype" : [ "" ],
"bgcolor" : [ 0.867, 0.867, 0.867, 1.0 ],
"fontsize" : 10.0,
"ignoreclick" : 0,
"patching_rect" : [ 571.0, 421.0, 32.5, 16.0 ],
"presentation" : 0,
"hidden" : 0
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "pak 2 0",
"numinlets" : 2,
"fontname" : "Arial",
"numoutlets" : 1,
"id" : "obj-7",
"textcolor" : [ 0.0, 0.0, 0.0, 1.0 ],
"presentation_rect" : [ 0.0, 0.0, 0.0, 0.0 ],
"background" : 0,
"color" : [ 0.8, 0.84, 0.71, 1.0 ],
"fontface" : 0,
"outlettype" : [ "" ],
"bgcolor" : [ 1.0, 1.0, 1.0, 1.0 ],
"fontsize" : 11.595187,
"ignoreclick" : 0,
"patching_rect" : [ 725.0, 480.0, 49.0, 20.0 ],
"presentation" : 0,
"hidden" : 0
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "pak 3 0",
"numinlets" : 2,
"fontname" : "Arial",
"numoutlets" : 1,
"id" : "obj-6",
"textcolor" : [ 0.0, 0.0, 0.0, 1.0 ],
"presentation_rect" : [ 0.0, 0.0, 0.0, 0.0 ],
"background" : 0,
"color" : [ 0.8, 0.84, 0.71, 1.0 ],
"fontface" : 0,
"outlettype" : [ "" ],
"bgcolor" : [ 1.0, 1.0, 1.0, 1.0 ],
"fontsize" : 11.595187,
"ignoreclick" : 0,
"patching_rect" : [ 606.0, 459.0, 49.0, 20.0 ],
"presentation" : 0,
"hidden" : 0
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "+ 100",
"numinlets" : 2,
"fontname" : "Arial",
"numoutlets" : 1,
"id" : "obj-4",
"textcolor" : [ 0.0, 0.0, 0.0, 1.0 ],
"presentation_rect" : [ 0.0, 0.0, 0.0, 0.0 ],
"background" : 0,
"color" : [ 0.8, 0.84, 0.71, 1.0 ],
"fontface" : 0,
"outlettype" : [ "int" ],
"bgcolor" : [ 1.0, 1.0, 1.0, 1.0 ],
"fontsize" : 12.0,
"ignoreclick" : 0,
"patching_rect" : [ 741.0, 364.0, 41.0, 20.0 ],
"presentation" : 0,
"hidden" : 0
}

}
, {
"box" : {
"maxclass" : "toggle",
"numinlets" : 1,
"numoutlets" : 1,
"bordercolor" : [ 0.5, 0.5, 0.5, 1.0 ],
"id" : "obj-46",
"presentation_rect" : [ 0.0, 0.0, 0.0, 0.0 ],
"background" : 0,
"outlettype" : [ "int" ],
"bgcolor" : [ 1.0, 1.0, 1.0, 1.0 ],
"ignoreclick" : 0,
"patching_rect" : [ 542.0, 492.0, 20.0, 20.0 ],
"presentation" : 0,
"checkedcolor" : [ 0.0, 0.0, 0.0, 1.0 ],
"hidden" : 0
}

}
, {
"box" : {
"maxclass" : "comment",
"text" : "Start polling to emty the serial buffer.",
"linecount" : 2,
"numinlets" : 1,
"fontname" : "Arial",
"numoutlets" : 0,
"id" : "obj-44",
"underline" : 0,
"textcolor" : [ 0.0, 0.0, 0.0, 1.0 ],
"presentation_rect" : [ 0.0, 0.0, 0.0, 0.0 ],
"background" : 0,
"fontface" : 0,
"bgcolor" : [ 1.0, 1.0, 1.0, 0.0 ],
"fontsize" : 10.0,
"ignoreclick" : 1,
"patching_rect" : [ 367.0, 454.0, 150.0, 29.0 ],
"presentation" : 0,
"hidden" : 0,
"frgb" : [ 0.0, 0.0, 0.0, 1.0 ]
}

}
, {
"box" : {
"maxclass" : "number",
"numinlets" : 1,
"fontname" : "Arial",
"htextcolor" : [ 1.0, 1.0, 1.0, 1.0 ],
"triscale" : 1.0,
"numoutlets" : 2,
"bordercolor" : [ 0.5, 0.5, 0.5, 1.0 ],
"id" : "obj-3",
"outputonclick" : 0,
"textcolor" : [ 0.0, 0.0, 0.0, 1.0 ],
"presentation_rect" : [ 0.0, 0.0, 0.0, 0.0 ],
"background" : 0,
"mouseup" : 0,
"fontface" : 0,
"outlettype" : [ "int", "bang" ],
"bgcolor" : [ 1.0, 1.0, 1.0, 1.0 ],
"triangle" : 1,
"fontsize" : 12.0,
"minimum" : "",
"ignoreclick" : 0,
"patching_rect" : [ 754.0, 308.0, 50.0, 20.0 ],
"format" : 0,
"htricolor" : [ 0.87, 0.82, 0.24, 1.0 ],
"maximum" : "
",
"presentation" : 0,
"hidden" : 0,
"cantchange" : 0,
"hbgcolor" : [ 0.0, 0.0, 0.0, 1.0 ],
"tricolor" : [ 0.75, 0.75, 0.75, 1.0 ]
}

}
, {
"box" : {
"maxclass" : "number",
"numinlets" : 1,
"fontname" : "Arial",
"htextcolor" : [ 1.0, 1.0, 1.0, 1.0 ],
"triscale" : 1.0,
"numoutlets" : 2,
"bordercolor" : [ 0.5, 0.5, 0.5, 1.0 ],
"id" : "obj-26",
"outputonclick" : 0,
"textcolor" : [ 0.0, 0.0, 0.0, 1.0 ],
"presentation_rect" : [ 0.0, 0.0, 0.0, 0.0 ],
"background" : 0,
"mouseup" : 0,
"fontface" : 0,
"outlettype" : [ "int", "bang" ],
"bgcolor" : [ 1.0, 1.0, 1.0, 1.0 ],
"triangle" : 1,
"fontsize" : 12.0,
"minimum" : "",
"ignoreclick" : 0,
"patching_rect" : [ 617.0, 360.0, 50.0, 20.0 ],
"format" : 0,
"htricolor" : [ 0.87, 0.82, 0.24, 1.0 ],
"maximum" : "
",
"presentation" : 0,
"hidden" : 0,
"cantchange" : 0,
"hbgcolor" : [ 0.0, 0.0, 0.0, 1.0 ],
"tricolor" : [ 0.75, 0.75, 0.75, 1.0 ]
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "prepend port",
"numinlets" : 1,
"fontname" : "Arial",
"numoutlets" : 1,
"id" : "obj-167",
"textcolor" : [ 0.0, 0.0, 0.0, 1.0 ],
"presentation_rect" : [ 0.0, 0.0, 0.0, 0.0 ],
"background" : 0,
"color" : [ 0.8, 0.84, 0.71, 1.0 ],
"fontface" : 0,
"outlettype" : [ "" ],
"bgcolor" : [ 1.0, 1.0, 1.0, 1.0 ],
"fontsize" : 12.0,
"ignoreclick" : 0,
"patching_rect" : [ 811.0, 15.0, 79.0, 20.0 ],
"presentation" : 0,
"hidden" : 0
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "route text",
"numinlets" : 1,
"fontname" : "Arial",
"numoutlets" : 2,
"id" : "obj-168",
"textcolor" : [ 0.0, 0.0, 0.0, 1.0 ],
"presentation_rect" : [ 0.0, 0.0, 0.0, 0.0 ],
"background" : 0,
"color" : [ 0.8, 0.84, 0.71, 1.0 ],
"fontface" : 0,
"outlettype" : [ "", "" ],
"bgcolor" : [ 1.0, 1.0, 1.0, 1.0 ],
"fontsize" : 12.0,
"ignoreclick" : 0,
"patching_rect" : [ 811.0, -17.0, 61.0, 20.0 ],
"presentation" : 0,
"hidden" : 0
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "pvar inputport",
"numinlets" : 1,
"fontname" : "Arial",
"numoutlets" : 1,
"id" : "obj-169",
"textcolor" : [ 0.0, 0.0, 0.0, 1.0 ],
"presentation_rect" : [ 0.0, 0.0, 0.0, 0.0 ],
"background" : 0,
"color" : [ 0.8, 0.84, 0.71, 1.0 ],
"fontface" : 0,
"outlettype" : [ "" ],
"bgcolor" : [ 1.0, 1.0, 1.0, 1.0 ],
"fontsize" : 12.0,
"ignoreclick" : 0,
"patching_rect" : [ 811.0, -47.0, 84.0, 20.0 ],
"presentation" : 0,
"hidden" : 0
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "* 21.3",
"numinlets" : 2,
"fontname" : "Arial",
"numoutlets" : 1,
"id" : "obj-151",
"textcolor" : [ 0.0, 0.0, 0.0, 1.0 ],
"presentation_rect" : [ 0.0, 0.0, 0.0, 0.0 ],
"background" : 0,
"color" : [ 0.8, 0.84, 0.71, 1.0 ],
"fontface" : 0,
"outlettype" : [ "float" ],
"bgcolor" : [ 1.0, 1.0, 1.0, 1.0 ],
"fontsize" : 12.0,
"ignoreclick" : 0,
"patching_rect" : [ 706.0, 73.0, 42.0, 20.0 ],
"presentation" : 0,
"hidden" : 0
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "+ 3.",
"numinlets" : 2,
"fontname" : "Arial",
"numoutlets" : 1,
"id" : "obj-152",
"textcolor" : [ 0.0, 0.0, 0.0, 1.0 ],
"presentation_rect" : [ 0.0, 0.0, 0.0, 0.0 ],
"background" : 0,
"color" : [ 0.8, 0.84, 0.71, 1.0 ],
"fontface" : 0,
"outlettype" : [ "float" ],
"bgcolor" : [ 1.0, 1.0, 1.0, 1.0 ],
"fontsize" : 12.0,
"ignoreclick" : 0,
"patching_rect" : [ 696.0, 44.0, 32.5, 20.0 ],
"presentation" : 0,
"hidden" : 0
}

}
, {
"box" : {
"maxclass" : "slider",
"orientation" : 0,
"numinlets" : 1,
"knobcolor" : [ 0.2, 0.2, 0.2, 1.0 ],
"numoutlets" : 1,
"bordercolor" : [ 0.5, 0.5, 0.5, 1.0 ],
"id" : "obj-153",
"presentation_rect" : [ 0.0, 0.0, 0.0, 0.0 ],
"background" : 0,
"size" : 128.0,
"outlettype" : [ "" ],
"bgcolor" : [ 1.0, 1.0, 1.0, 1.0 ],
"relative" : 0,
"ignoreclick" : 0,
"patching_rect" : [ 716.0, 248.0, 181.0, 13.0 ],
"floatoutput" : 1,
"presentation" : 0,
"mult" : 1.0,
"min" : 0.0,
"hidden" : 0
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "* 21.3",
"numinlets" : 2,
"fontname" : "Arial",
"numoutlets" : 1,
"id" : "obj-142",
"textcolor" : [ 0.0, 0.0, 0.0, 1.0 ],
"presentation_rect" : [ 0.0, 0.0, 0.0, 0.0 ],
"background" : 0,
"color" : [ 0.8, 0.84, 0.71, 1.0 ],
"fontface" : 0,
"outlettype" : [ "float" ],
"bgcolor" : [ 1.0, 1.0, 1.0, 1.0 ],
"fontsize" : 12.0,
"ignoreclick" : 0,
"patching_rect" : [ 661.0, 73.0, 42.0, 20.0 ],
"presentation" : 0,
"hidden" : 0
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "+ 3.",
"numinlets" : 2,
"fontname" : "Arial",
"numoutlets" : 1,
"id" : "obj-143",
"textcolor" : [ 0.0, 0.0, 0.0, 1.0 ],
"presentation_rect" : [ 0.0, 0.0, 0.0, 0.0 ],
"background" : 0,
"color" : [ 0.8, 0.84, 0.71, 1.0 ],
"fontface" : 0,
"outlettype" : [ "float" ],
"bgcolor" : [ 1.0, 1.0, 1.0, 1.0 ],
"fontsize" : 12.0,
"ignoreclick" : 0,
"patching_rect" : [ 661.0, 43.0, 32.5, 20.0 ],
"presentation" : 0,
"hidden" : 0
}

}
, {
"box" : {
"maxclass" : "slider",
"orientation" : 0,
"numinlets" : 1,
"knobcolor" : [ 0.2, 0.2, 0.2, 1.0 ],
"numoutlets" : 1,
"bordercolor" : [ 0.5, 0.5, 0.5, 1.0 ],
"id" : "obj-144",
"presentation_rect" : [ 0.0, 0.0, 0.0, 0.0 ],
"background" : 0,
"size" : 128.0,
"outlettype" : [ "" ],
"bgcolor" : [ 1.0, 1.0, 1.0, 1.0 ],
"relative" : 0,
"ignoreclick" : 0,
"patching_rect" : [ 627.0, 153.0, 13.0, 180.0 ],
"floatoutput" : 1,
"presentation" : 0,
"mult" : 1.0,
"min" : 0.0,
"hidden" : 0
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "unpack 1. 1. 1.",
"numinlets" : 1,
"fontname" : "Arial",
"numoutlets" : 3,
"id" : "obj-57",
"textcolor" : [ 0.0, 0.0, 0.0, 1.0 ],
"presentation_rect" : [ 0.0, 0.0, 0.0, 0.0 ],
"background" : 0,
"color" : [ 0.8, 0.84, 0.71, 1.0 ],
"fontface" : 0,
"outlettype" : [ "float", "float", "float" ],
"bgcolor" : [ 1.0, 1.0, 1.0, 1.0 ],
"fontsize" : 12.0,
"ignoreclick" : 0,
"patching_rect" : [ 661.0, 13.0, 89.0, 20.0 ],
"presentation" : 0,
"hidden" : 0
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "route /acceleration/xyz",
"numinlets" : 1,
"fontname" : "Arial",
"numoutlets" : 2,
"id" : "obj-55",
"textcolor" : [ 0.0, 0.0, 0.0, 1.0 ],
"presentation_rect" : [ 0.0, 0.0, 0.0, 0.0 ],
"background" : 0,
"color" : [ 0.8, 0.84, 0.71, 1.0 ],
"fontface" : 0,
"outlettype" : [ "", "" ],
"bgcolor" : [ 1.0, 1.0, 1.0, 1.0 ],
"fontsize" : 12.0,
"ignoreclick" : 0,
"patching_rect" : [ 661.0, -17.0, 131.0, 20.0 ],
"presentation" : 0,
"hidden" : 0
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "udpreceive 7000",
"numinlets" : 1,
"fontname" : "Arial",
"numoutlets" : 1,
"id" : "obj-43",
"textcolor" : [ 0.0, 0.0, 0.0, 1.0 ],
"presentation_rect" : [ 0.0, 0.0, 0.0, 0.0 ],
"background" : 0,
"color" : [ 0.8, 0.84, 0.71, 1.0 ],
"fontface" : 0,
"outlettype" : [ "" ],
"bgcolor" : [ 1.0, 1.0, 1.0, 1.0 ],
"fontsize" : 12.0,
"ignoreclick" : 0,
"patching_rect" : [ 661.0, -47.0, 99.0, 20.0 ],
"presentation" : 0,
"hidden" : 0
}

}
, {
"box" : {
"maxclass" : "comment",
"text" : "< start polling the serial port",
"numinlets" : 1,
"fontname" : "Arial",
"numoutlets" : 0,
"id" : "obj-18",
"underline" : 0,
"textcolor" : [ 0.0, 0.0, 0.0, 1.0 ],
"presentation_rect" : [ 0.0, 0.0, 0.0, 0.0 ],
"background" : 0,
"fontface" : 0,
"bgcolor" : [ 1.0, 1.0, 1.0, 0.0 ],
"fontsize" : 11.595187,
"ignoreclick" : 1,
"patching_rect" : [ 571.0, 493.0, 153.0, 20.0 ],
"presentation" : 0,
"hidden" : 0,
"frgb" : [ 0.0, 0.0, 0.0, 1.0 ]
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "metro 1",
"numinlets" : 2,
"fontname" : "Arial",
"numoutlets" : 1,
"id" : "obj-5",
"textcolor" : [ 0.0, 0.0, 0.0, 1.0 ],
"presentation_rect" : [ 0.0, 0.0, 0.0, 0.0 ],
"background" : 0,
"color" : [ 0.8, 0.84, 0.71, 1.0 ],
"fontface" : 0,
"outlettype" : [ "bang" ],
"bgcolor" : [ 1.0, 1.0, 1.0, 1.0 ],
"fontsize" : 11.595187,
"ignoreclick" : 0,
"patching_rect" : [ 538.0, 545.0, 50.0, 20.0 ],
"presentation" : 0,
"hidden" : 0
}

}
, {
"box" : {
"maxclass" : "message",
"text" : "print",
"bgcolor2" : [ 0.867, 0.867, 0.867, 1.0 ],
"numinlets" : 2,
"fontname" : "Arial",
"gradient" : 0,
"numoutlets" : 1,
"id" : "obj-2",
"textcolor" : [ 0.0, 0.0, 0.0, 1.0 ],
"presentation_rect" : [ 0.0, 0.0, 0.0, 0.0 ],
"background" : 0,
"fontface" : 0,
"outlettype" : [ "" ],
"bgcolor" : [ 0.867, 0.867, 0.867, 1.0 ],
"fontsize" : 11.595187,
"ignoreclick" : 0,
"patching_rect" : [ 648.0, 550.0, 33.0, 18.0 ],
"presentation" : 0,
"hidden" : 0
}

}
, {
"box" : {
"maxclass" : "newobj",
"text" : "serial d 19200",
"numinlets" : 1,
"fontname" : "Arial",
"numoutlets" : 2,
"id" : "obj-1",
"textcolor" : [ 0.0, 0.0, 0.0, 1.0 ],
"presentation_rect" : [ 0.0, 0.0, 0.0, 0.0 ],
"background" : 0,
"color" : [ 0.356863, 0.768627, 0.0, 1.0 ],
"fontface" : 0,
"outlettype" : [ "int", "" ],
"bgcolor" : [ 1.0, 1.0, 1.0, 1.0 ],
"fontsize" : 11.595187,
"ignoreclick" : 0,
"patching_rect" : [ 648.0, 584.0, 83.0, 20.0 ],
"presentation" : 0,
"hidden" : 0
}

}
],
"lines" : [ {
"patchline" : {
"source" : [ "obj-11", 0 ],
"destination" : [ "obj-7", 0 ],
"hidden" : 0,
"color" : [ 0.0, 0.0, 0.0, 1.0 ],
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-10", 0 ],
"destination" : [ "obj-6", 0 ],
"hidden" : 0,
"color" : [ 0.0, 0.0, 0.0, 1.0 ],
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-26", 0 ],
"destination" : [ "obj-6", 1 ],
"hidden" : 0,
"color" : [ 0.0, 0.0, 0.0, 1.0 ],
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-6", 0 ],
"destination" : [ "obj-1", 0 ],
"hidden" : 0,
"color" : [ 0.0, 0.0, 0.0, 1.0 ],
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-7", 0 ],
"destination" : [ "obj-1", 0 ],
"hidden" : 0,
"color" : [ 0.0, 0.0, 0.0, 1.0 ],
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-4", 0 ],
"destination" : [ "obj-7", 1 ],
"hidden" : 0,
"color" : [ 0.0, 0.0, 0.0, 1.0 ],
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-151", 0 ],
"destination" : [ "obj-153", 0 ],
"hidden" : 0,
"color" : [ 0.0, 0.0, 0.0, 1.0 ],
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-152", 0 ],
"destination" : [ "obj-151", 0 ],
"hidden" : 0,
"color" : [ 0.0, 0.0, 0.0, 1.0 ],
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-2", 0 ],
"destination" : [ "obj-1", 0 ],
"hidden" : 0,
"color" : [ 0.0, 0.0, 0.0, 1.0 ],
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-5", 0 ],
"destination" : [ "obj-1", 0 ],
"hidden" : 0,
"color" : [ 0.0, 0.0, 0.0, 1.0 ],
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-142", 0 ],
"destination" : [ "obj-144", 0 ],
"hidden" : 0,
"color" : [ 0.0, 0.0, 0.0, 1.0 ],
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-153", 0 ],
"destination" : [ "obj-3", 0 ],
"hidden" : 0,
"color" : [ 0.0, 0.0, 0.0, 1.0 ],
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-144", 0 ],
"destination" : [ "obj-26", 0 ],
"hidden" : 0,
"color" : [ 0.0, 0.0, 0.0, 1.0 ],
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-55", 0 ],
"destination" : [ "obj-57", 0 ],
"hidden" : 0,
"color" : [ 0.0, 0.0, 0.0, 1.0 ],
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-143", 0 ],
"destination" : [ "obj-142", 0 ],
"hidden" : 0,
"color" : [ 0.0, 0.0, 0.0, 1.0 ],
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-57", 0 ],
"destination" : [ "obj-143", 0 ],
"hidden" : 0,
"color" : [ 0.0, 0.0, 0.0, 1.0 ],
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-57", 1 ],
"destination" : [ "obj-152", 0 ],
"hidden" : 0,
"color" : [ 0.0, 0.0, 0.0, 1.0 ],
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-168", 0 ],
"destination" : [ "obj-167", 0 ],
"hidden" : 0,
"color" : [ 0.0, 0.0, 0.0, 1.0 ],
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-169", 0 ],
"destination" : [ "obj-168", 0 ],
"hidden" : 0,
"color" : [ 0.0, 0.0, 0.0, 1.0 ],
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-43", 0 ],
"destination" : [ "obj-55", 0 ],
"hidden" : 0,
"color" : [ 0.0, 0.0, 0.0, 1.0 ],
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-167", 0 ],
"destination" : [ "obj-43", 0 ],
"hidden" : 0,
"color" : [ 0.0, 0.0, 0.0, 1.0 ],
"midpoints" : [ 820.5, 45.0, 800.0, 45.0, 800.0, -53.0, 670.5, -53.0 ]
}

}
, {
"patchline" : {
"source" : [ "obj-46", 0 ],
"destination" : [ "obj-5", 0 ],
"hidden" : 0,
"color" : [ 0.0, 0.0, 0.0, 1.0 ],
"midpoints" : [ ]
}

}
, {
"patchline" : {
"source" : [ "obj-3", 0 ],
"destination" : [ "obj-4", 0 ],
"hidden" : 0,
"color" : [ 0.0, 0.0, 0.0, 1.0 ],
"midpoints" : [ ]
}

}
]
}

Arduino code:

//SENDER
int ReadyToTransmit = 5; //sets the readytotransmitpin to 5
int ReadyToReceive = 6; //same
int serialvalue; // value for serial input(sent from max)
char id;
int throttle;
int turn;

void setup()

{
pinMode(ReadyToTransmit, OUTPUT); // declairs readytotransmitpit as output
digitalWrite(ReadyToTransmit, HIGH); // declairs readytotransmitpit as high6
Serial.begin(19200); // open the arduino serial port
}

void loop()
{
while(Serial.available() > 1) // check to see if there’s serial data in the buffer(waiting to be handled
{
id = Serial.read(); // read a byte of serial data and names the value serialvalue
serialvalue = Serial.read();

if (id == 1){
throttle = serialvalue + 100;
}

if (id ==2){
turn = serialvalue;
}
Serial.write(throttle);
delay(5);
Serial.write(turn);
delay(30);
}
}


Viewing 12 posts - 1 through 12 (of 12 total)