PureData

#N canvas 564 22 889 913 10;
#X declare -lib moocow;
#X obj 44 221 comport 1 9600;
#X obj 18 114 select 0 1;
#X obj 16 81 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0 1
;
#X msg 24 161 close;
#X msg 155 168 ports;
#X obj 125 251 route ports;
#X obj 125 277 print port_list;
#X text 154 187 will print out available ports to message window;
#X text 45 80 toggle to open serial port;
#X obj -133 94 loadbang;
#X msg -132 120 pollintervall 10;
#X obj 38 408 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
#X obj -6 136 t 0 b;
#X obj 38 439 t b f;
#X msg 36 473 1;
#X obj 102 474 - 0;
#X obj 96 307 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1
1;
#X obj 51 333 spigot 1;
#X obj -11 439 sel 1;
#X msg -40 510 65;
#X obj -120 400 spigot;
#X obj -131 635 unpack 0 0 0;
#X floatatom -154 683 5 0 0 0 - - -;
#X floatatom -96 684 5 0 0 0 - - -;
#X floatatom -38 682 5 0 0 0 - - -;
#X text -240 62 Read serial input buffer every 10 milliseconds;
#X text 113 354 checks for the ascii value of "A" to begin cominucation.
After initial communication is made \, this block shuts down.;
#X text 54 401 reinitializes the gates when turned on and off;
#X text -114 571 trigger (or [t]) forces right-left conventions. All
the drawing and processing will happen before PD requests new values.
When this trigger fires \, it sends an ASCII A to ask Arduino for new
values.;
#X text -26 663 val3;
#X text -137 667 val1;
#X text -82 665 val2;
#X obj 300 541 cnv 15 140 65 empty empty empty 20 12 0 14 -195568 -66577
0;
#X msg 315 561 create;
#X text 311 540 Create window:;
#N canvas 475 403 450 300 gemwin 0;
#X obj 67 89 outlet;
#X obj 67 10 inlet;
#X obj 67 41 route create;
#X msg 67 70 set destroy;
#X msg 142 68 set create;
#X msg 132 93 create \, 1 \, frame 2;
#X msg 198 112 destroy \, reset;
#X obj 132 136 gemwin 33;
#X connect 1 0 2 0;
#X connect 2 0 3 0;
#X connect 2 0 5 0;
#X connect 2 1 4 0;
#X connect 2 1 6 0;
#X connect 3 0 0 0;
#X connect 4 0 0 0;
#X connect 5 0 7 0;
#X connect 6 0 7 0;
#X restore 315 581 pd gemwin;
#X obj 316 635 gemhead;
#X obj -34 713 sel 255 0;
#X msg 352 677 0 0 0;
#X msg 415 674 1 1 1;
#X obj 316 705 color 1 1 1;
#X obj 313 834 circle;
#X obj 313 780 translateXYZ;
#X obj -154 716 / 255;
#X obj -154 745 * 5;
#X obj -151 772 - 2.5;
#X obj -98 709 / 255;
#X obj -98 738 * 5;
#X obj -95 765 - 2.5;
#X obj -181 179 import moocow;
#X msg 74 163 open 4;
#X msg -219 179 3;
#X obj 50 369 sel 10;
#X obj -163 584 t b l;
#X obj -40 473 delay 1000;
#N canvas 0 22 747 1006 parse_ASCII_to_ints 0;
#X obj 97 52 inlet;
#X obj 24 646 outlet;
#X obj 516 211 sel 44;
#X obj 232 200 sel 44;
#X obj 121 199 sel 10 13;
#X obj 516 244 t b 2;
#X obj 92 247 t b 3;
#X obj 233 164 gate 3 3;
#X floatatom 188 130 5 0 0 0 - - -;
#X msg 191 162 1;
#X msg 121 161 3;
#X msg 541 172 2;
#X obj 265 286 bytes2any;
#X obj 265 311 tolist;
#X obj 288 533 sprintf %d%d%d;
#X obj 232 251 t b 1;
#X obj 260 564 i;
#X obj 276 454 sprintf %d%d;
#X obj 214 360 list length;
#X obj 265 334 t l l;
#X obj 261 389 gate 3;
#X obj 276 417 list split 1;
#X obj 361 453 list split 1;
#X obj 375 422 list split 2;
#X obj 520 294 bytes2any;
#X obj 520 319 tolist;
#X obj 543 541 sprintf %d%d%d;
#X obj 515 572 i;
#X obj 531 462 sprintf %d%d;
#X obj 469 368 list length;
#X obj 520 342 t l l;
#X obj 516 397 gate 3;
#X obj 531 425 list split 1;
#X obj 616 461 list split 1;
#X obj 630 430 list split 2;
#X obj 34 293 bytes2any;
#X obj 34 318 tolist;
#X obj 57 540 sprintf %d%d%d;
#X obj 29 571 i;
#X obj 45 461 sprintf %d%d;
#X obj -17 367 list length;
#X obj 34 341 t l l;
#X obj 30 396 gate 3;
#X obj 45 424 list split 1;
#X obj 130 460 list split 1;
#X obj 144 429 list split 2;
#X obj 26 595 pack 0 0 0;
#X obj 412 60 inlet;
#X connect 0 0 8 0;
#X connect 2 0 5 0;
#X connect 2 1 24 0;
#X connect 3 0 15 0;
#X connect 3 1 12 0;
#X connect 4 1 6 0;
#X connect 4 2 35 0;
#X connect 5 0 25 1;
#X connect 5 1 11 0;
#X connect 6 0 36 1;
#X connect 6 1 10 0;
#X connect 7 0 4 0;
#X connect 7 1 3 0;
#X connect 7 2 2 0;
#X connect 8 0 7 0;
#X connect 9 0 8 0;
#X connect 10 0 8 0;
#X connect 11 0 8 0;
#X connect 12 0 13 0;
#X connect 13 0 19 0;
#X connect 14 0 16 0;
#X connect 15 0 13 1;
#X connect 15 1 9 0;
#X connect 16 0 46 1;
#X connect 17 0 16 0;
#X connect 18 0 20 0;
#X connect 19 0 18 0;
#X connect 19 1 20 1;
#X connect 20 0 16 0;
#X connect 20 1 21 0;
#X connect 20 2 23 0;
#X connect 21 0 17 0;
#X connect 21 1 17 1;
#X connect 22 0 14 0;
#X connect 22 1 14 1;
#X connect 23 0 22 0;
#X connect 23 1 14 2;
#X connect 24 0 25 0;
#X connect 25 0 30 0;
#X connect 26 0 27 0;
#X connect 27 0 46 2;
#X connect 28 0 27 0;
#X connect 29 0 31 0;
#X connect 30 0 29 0;
#X connect 30 1 31 1;
#X connect 31 0 27 0;
#X connect 31 1 32 0;
#X connect 31 2 34 0;
#X connect 32 0 28 0;
#X connect 32 1 28 1;
#X connect 33 0 26 0;
#X connect 33 1 26 1;
#X connect 34 0 33 0;
#X connect 34 1 26 2;
#X connect 35 0 36 0;
#X connect 36 0 41 0;
#X connect 37 0 38 0;
#X connect 38 0 46 0;
#X connect 39 0 38 0;
#X connect 40 0 42 0;
#X connect 41 0 40 0;
#X connect 41 1 42 1;
#X connect 42 0 38 0;
#X connect 42 1 43 0;
#X connect 42 2 45 0;
#X connect 43 0 39 0;
#X connect 43 1 39 1;
#X connect 44 0 37 0;
#X connect 44 1 37 1;
#X connect 45 0 44 0;
#X connect 45 1 37 2;
#X connect 46 0 1 0;
#X connect 47 0 7 1;
#X restore -200 454 pd parse_ASCII_to_ints;
#X text 267 -37 Serial Call-Response ASCII Sends a byte out the serial
port \, and reads 3 ASCII enoded \, comma separated in \, truncated
by a linefeed. It then sets foregound color \, xpos \, and ypos of
a circle using the values returned from the serial port. Note: This
patch assumes that the device on the other end of the serial port is
going to send a byte of value 10 (the trailing end of a carrige return
in ASCII) on startup. The sketch waits for that byte \, then sends
an ASCII A whenever it wants more data. Oct 15 \, 2010 by Scott Fitzgerald
\, based off the Serial Call and Rsponse Max/MSP example by Tom Igoe
and myself;
#X connect 0 0 17 0;
#X connect 0 0 20 0;
#X connect 0 1 5 0;
#X connect 1 0 12 0;
#X connect 1 1 50 0;
#X connect 2 0 1 0;
#X connect 3 0 0 0;
#X connect 4 0 0 0;
#X connect 5 0 6 0;
#X connect 9 0 10 0;
#X connect 9 0 49 0;
#X connect 9 0 51 0;
#X connect 10 0 0 0;
#X connect 11 0 13 0;
#X connect 11 0 18 0;
#X connect 11 0 20 1;
#X connect 12 0 11 0;
#X connect 12 1 3 0;
#X connect 13 0 14 0;
#X connect 13 1 15 1;
#X connect 14 0 15 0;
#X connect 15 0 16 0;
#X connect 16 0 17 1;
#X connect 17 0 52 0;
#X connect 18 0 54 0;
#X connect 19 0 0 0;
#X connect 20 0 55 1;
#X connect 21 0 22 0;
#X connect 21 1 23 0;
#X connect 21 2 24 0;
#X connect 22 0 43 0;
#X connect 23 0 46 0;
#X connect 24 0 37 0;
#X connect 33 0 35 0;
#X connect 35 0 33 0;
#X connect 36 0 40 0;
#X connect 37 0 38 0;
#X connect 37 1 39 0;
#X connect 38 0 40 1;
#X connect 39 0 40 1;
#X connect 40 0 42 0;
#X connect 42 0 41 0;
#X connect 43 0 44 0;
#X connect 44 0 45 0;
#X connect 45 0 42 1;
#X connect 46 0 47 0;
#X connect 47 0 48 0;
#X connect 48 0 42 2;
#X connect 50 0 0 0;
#X connect 51 0 55 0;
#X connect 52 0 11 0;
#X connect 53 0 19 0;
#X connect 53 1 21 0;
#X connect 54 0 19 0;
#X connect 55 0 53 0;