{"id":113,"date":"2007-10-10T22:10:19","date_gmt":"2007-10-11T03:10:19","guid":{"rendered":"http:\/\/www.tigoe.net\/pcomp\/code\/category\/code\/arduinowiring\/113"},"modified":"2007-10-10T22:28:55","modified_gmt":"2007-10-11T03:28:55","slug":"virtual-color-fader-for-maxmsp","status":"publish","type":"post","link":"https:\/\/www.tigoe.com\/pcomp\/code\/arduinowiring\/113\/","title":{"rendered":"Virtual Color Fader for Max\/MSP"},"content":{"rendered":"<p>This Max\/MSP patch reads in a serial string like this:<\/p>\n<p><code>Rnnn<br \/>\nGnnn<br \/>\nBnnn<\/code><\/p>\n<p>Where nnn is an ASCII-formatted decimal number from 0 to 255.  It then converts the values into the RGB colod for the patch&#8217;s background.<\/p>\n<p>An Arduino program to send the appropriate data follows.<\/p>\n<p>To use the patch, copy the text and paste it into a new max patch window.<\/p>\n<p>Thanks to David Mellis and Jamie Allen for the collaboration. These patches were written for a one-day Arduino workshop at NIME 07 hosted by the three of us. The Arduino program comes from the Arduino example files, by David Mellis.<\/p>\n<p><!-- technorati tags start --><\/p>\n<p style=\"text-align:right;font-size:10px;\">Technorati Tags: <a href=\"http:\/\/www.technorati.com\/tag\/arduino\" rel=\"tag\">arduino<\/a>, <a href=\"http:\/\/www.technorati.com\/tag\/pcomp\" rel=\"tag\">pcomp<\/a>, <a href=\"http:\/\/www.technorati.com\/tag\/physical computing\" rel=\"tag\">physical computing<\/a><\/p>\n<p><!-- technorati tags end --><br \/>\n<!--more--><br \/>\n<a href=\"https:\/\/tigoe.com\/pcomp\/code\/wp-content\/uploads\/2007\/10\/virtualcolorfader.png\" title=\"virtualcolorfader.png\"><img decoding=\"async\" src=\"https:\/\/tigoe.com\/pcomp\/code\/wp-content\/uploads\/2007\/10\/virtualcolorfader.thumbnail.png\" alt=\"virtualcolorfader.png\" \/><\/a><\/p>\n<pre>max v2;\n#N vpatcher 0 44 587 638;\n#P window setfont \"Sans Serif\" 9.;\n#P comment 137 34 100 196617 Read the serial port every two milliseconds;\n#P window linecount 1;\n#P newex 156 276 27 196617 \/ 4;\n#P number 156 254 35 9 0 1023 3 3 0 0 0 221 221 221 222 222 222 0 0 0;\n#P newex 106 276 27 196617 \/ 4;\n#P number 106 254 35 9 0 1023 3 3 0 0 0 221 221 221 222 222 222 0 0 0;\n#P newex 55 276 27 196617 \/ 4;\n#P number 55 254 35 9 0 1023 3 3 0 0 0 221 221 221 222 222 222 0 0 0;\n#P hidden newex 55 303 112 196617 bgcolor 220 120 192;\n#P user multiSlider 167 145 125 91 0. 1023. 1 3449 15 0 0 2 0 0 0;\n#M frgb 0 0 0;\n#M brgb 255 255 255;\n#M rgb2 127 127 127;\n#M rgb3 0 0 0;\n#M rgb4 37 52 91;\n#M rgb5 74 105 182;\n#M rgb6 112 158 18;\n#M rgb7 149 211 110;\n#M rgb8 187 9 201;\n#M rgb9 224 62 37;\n#M rgb10 7 114 128;\n#P user multiSlider 438 145 125 91 0. 1023. 1 3449 15 0 0 2 0 0 0;\n#M frgb 0 0 0;\n#M brgb 255 255 255;\n#M rgb2 127 127 127;\n#M rgb3 0 0 0;\n#M rgb4 37 52 91;\n#M rgb5 74 105 182;\n#M rgb6 112 158 18;\n#M rgb7 149 211 110;\n#M rgb8 187 9 201;\n#M rgb9 224 62 37;\n#M rgb10 7 114 128;\n#P user multiSlider 301 144 125 91 0. 1023. 1 3449 15 0 0 2 0 0 0;\n#M frgb 0 0 0;\n#M brgb 255 255 255;\n#M rgb2 127 127 127;\n#M rgb3 0 0 0;\n#M rgb4 37 52 91;\n#M rgb5 74 105 182;\n#M rgb6 112 158 18;\n#M rgb7 149 211 110;\n#M rgb8 187 9 201;\n#M rgb9 224 62 37;\n#M rgb10 7 114 128;\n#N vpatcher 20 74 303 387;\n#P window setfont \"Sans Serif\" 9.;\n#P newex 92 248 62 196617 fromsymbol;\n#B color 5;\n#P message 134 231 73 196617;\n#P newex 134 211 62 196617 prepend set;\n#B color 5;\n#P newex 92 211 40 196617 itoa;\n#B color 5;\n#P newex 92 191 55 196617 zl group 4;\n#P newex 50 158 52 196617 select 10;\n#P message 130 86 14 196617 1;\n#P message 112 86 14 196617 0;\n#P newex 50 132 27 196617 gate;\n#P newex 130 64 52 196617 select 82;\n#P comment 151 45 25 196617 \"R\";\n#P inlet 130 44 15 0;\n#P outlet 92 270 15 0;\n#P fasten 5 0 4 0 117 111 55 111;\n#P fasten 6 0 4 0 135 111 55 111;\n#P connect 4 0 7 0;\n#P fasten 3 1 4 1 177 128 72 128;\n#P connect 7 0 8 0;\n#P connect 7 1 8 0;\n#P connect 8 0 9 0;\n#P connect 9 0 12 0;\n#P connect 12 0 0 0;\n#P connect 7 0 5 0;\n#P connect 1 0 3 0;\n#P connect 3 0 6 0;\n#P connect 9 0 10 0;\n#P connect 10 0 11 0;\n#P pop;\n#P newobj 55 96 49 196617 p parseR;\n#N vpatcher 20 74 620 474;\n#P window setfont \"Sans Serif\" 9.;\n#P newex 92 250 62 196617 fromsymbol;\n#B color 5;\n#P message 134 233 73 196617 501\n;\n#P newex 134 213 62 196617 prepend set;\n#B color 5;\n#P newex 92 213 40 196617 itoa;\n#B color 5;\n#P newex 92 193 55 196617 zl group 4;\n#P newex 50 160 52 196617 select 10;\n#P message 130 88 14 196617 1;\n#P message 112 88 14 196617 0;\n#P newex 50 134 27 196617 gate;\n#P newex 130 66 52 196617 select 66;\n#P comment 169 50 25 196617 \"B\";\n#P inlet 130 46 15 0;\n#P outlet 92 272 15 0;\n#P fasten 5 0 4 0 117 113 55 113;\n#P fasten 6 0 4 0 135 113 55 113;\n#P connect 4 0 7 0;\n#P fasten 3 1 4 1 177 130 72 130;\n#P connect 7 0 8 0;\n#P connect 7 1 8 0;\n#P connect 8 0 9 0;\n#P connect 9 0 12 0;\n#P connect 12 0 0 0;\n#P connect 7 0 5 0;\n#P connect 1 0 3 0;\n#P connect 3 0 6 0;\n#P connect 9 0 10 0;\n#P connect 10 0 11 0;\n#P pop;\n#P newobj 156 96 49 196617 p parseB;\n#N vpatcher 589 252 861 563;\n#P window setfont \"Sans Serif\" 9.;\n#P comment 153 47 25 196617 \"G\";\n#P newex 92 250 62 196617 fromsymbol;\n#B color 5;\n#P message 134 233 73 196617 718;\n#P newex 134 213 62 196617 prepend set;\n#B color 5;\n#P newex 92 213 40 196617 itoa;\n#B color 5;\n#P newex 92 193 55 196617 zl group 4;\n#P newex 50 160 52 196617 select 10;\n#P message 130 88 14 196617 1;\n#P message 112 88 14 196617 0;\n#P newex 50 134 27 196617 gate;\n#P newex 130 66 52 196617 select 71;\n#P inlet 130 46 15 0;\n#P outlet 92 272 15 0;\n#P fasten 5 0 3 0 135 113 55 113;\n#P fasten 4 0 3 0 117 113 55 113;\n#P connect 3 0 6 0;\n#P fasten 2 1 3 1 177 130 72 130;\n#P connect 6 0 7 0;\n#P connect 6 1 7 0;\n#P connect 7 0 8 0;\n#P connect 8 0 11 0;\n#P connect 11 0 0 0;\n#P connect 6 0 4 0;\n#P connect 1 0 2 0;\n#P connect 2 0 5 0;\n#P connect 8 0 9 0;\n#P connect 9 0 10 0;\n#P pop;\n#P newobj 106 96 49 196617 p parseG;\n#P toggle 55 34 15 0;\n#P hidden newex 55 52 46 196617 metro 2;\n#P newex 55 72 71 196617 serial a 9600;\n#B color 5;\n#P window linecount 3;\n#P comment 319 50 100 196617 Virtual Color Fader Most of the code by Jamie Allen;\n#P connect 3 0 2 0;\n#P connect 2 0 1 0;\n#P connect 1 0 6 0;\n#P connect 6 0 11 0;\n#P connect 11 0 12 0;\n#P fasten 12 0 10 0 60 298 60 298;\n#P fasten 1 0 4 0 60 92 111 92;\n#P fasten 4 0 13 0 111 243 111 243;\n#P connect 13 0 14 0;\n#P connect 14 0 10 1;\n#P fasten 1 0 5 0 60 92 161 92;\n#P fasten 5 0 15 0 161 243 161 243;\n#P connect 15 0 16 0;\n#P fasten 16 0 10 2 161 298 162 298;\n#P fasten 6 0 9 0 60 129 172 129;\n#P fasten 4 0 7 0 111 129 306 129;\n#P fasten 5 0 8 0 161 129 443 129;\n#P pop;\n<\/pre>\n<p>Arduino program:<\/p>\n<pre>int redPin = 0;\nint greenPin = 1;\nint bluePin = 2;\nvoid setup()\n{\n  Serial.begin(9600);\n}\n\nvoid loop()\n{\n  Serial.print(\"R\");\n  Serial.println(analogRead(redPin));\n  Serial.print(\"G\");\n  Serial.println(analogRead(greenPin));\n  Serial.print(\"B\");\n  Serial.println(analogRead(bluePin));\n  delay(100);\n}\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This Max\/MSP patch reads in a serial string like this:RnnnGnnnBnnnmax v2;#N vpatcher 0 44 587 638;#P window setfont &#8220;Sans Serif&#8221; 9.;#P comment 137 34 100 196617 Read the serial port every two milliseconds;#P window linecount 1;#P newex 156 276 27 196617 \/ 4;#P number 156 254 35 9 0 1023 3 3 0 0 0 221 221 221 222 222 222 0 0 0;#P newex 106 276 27 196617 \/ 4;#P number 106 254 35 9 0 1023 3 3 0 0 0 221 221 221 222 222 222 0 0 0;#P newex 55 276 27 196617 \/ 4;#P number 55 254 35 9 0 1023 3 3 0 0 0 221 221 221 222 222 222 0 0 0;#P hidden newex 55 303 112 196617 bgcolor 220 120 192;#P user multiSlider 167 145 125 91 0&#8230;.  1 3449 15 0 0 2 0 0 0;#M frgb 0 0 0;#M brgb 255 255 255;#M rgb2 127 127 127;#M rgb3 0 0 0;#M rgb4 37 52 91;#M rgb5 74 105 182;#M rgb6 112 158 18;#M rgb7 149 211 110;#M rgb8 187 9 201;#M rgb9 224 62 37;#M rgb10 7 114 128;#P user multiSlider 438 145 125 91 0.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,15],"tags":[],"class_list":["post-113","post","type-post","status-publish","format-standard","hentry","category-arduinowiring","category-MaxMSP"],"_links":{"self":[{"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/posts\/113","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/comments?post=113"}],"version-history":[{"count":0,"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/posts\/113\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/media?parent=113"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/categories?post=113"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tigoe.com\/pcomp\/code\/wp-json\/wp\/v2\/tags?post=113"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}