rhoadley.net   music   research   software   blogs

aru    seminars    m&t    critski    focm1a    cmc    circuit bending    mic2b    sensor technology    comp 3    sonic art    major project
youtube    vimeo    facebook


Resources:    Bioacoustics    Jitter    MaxMSP    OSC    Physical    PD       CBHH    sTech    SuperCollider    C/Xcode

sTech Resources:     Home     Blog     Forum     Examples     Projects     Tasks     Tutorials


Sensor Technology Tasks

Max To Arduino

Not currently a task

Communicating to an Arduino from Max

Max Patch

(Load this after you've loaded the Arduino code.)

Small version

#P window setfont "Sans Serif" 9.;
#P number 327 110 35 9 0 255 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P user uslider 286 66 18 128 255 1 0 0;
#P window linecount 1;
#P message 212 192 32 196617 print;
#P newex 286 217 71 196617 serial a 9600;
#P window linecount 3;
#P comment 313 67 100 196617 Slide the fader or use the number box to dim the LED;
#P window linecount 2;
#P comment 69 192 125 196617 Click here to get a list of serial ports;
#P fasten 5 0 2 0 332 213 291 213;
#P fasten 3 0 2 0 217 212 291 212;
#P fasten 4 0 2 0 291 215 291 215;
#P window clipboard copycount 6;


More complex with live interactive groove~!

#P button 465 166 15 0;
#P toggle 446 213 15 0;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 446 235 29 196617 gate;
#P toggle 426 167 15 0;
#N vpatcher 220 44 1005 758;
#P outlet 429 592 15 0;
#P window setfont "Sans Serif" 9.;
#P message 573 543 26 196617 255;
#P message 523 543 14 196617 0;
#P newex 523 497 60 196617 split 0. 0.5;
#P newex 429 560 53 196617 * 255.99;
#P number 493 433 35 9 0 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 429 527 58 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 430 457 69 196617 peakamp~ 10;
#B color 5;
#P outlet 554 591 15 0;
#N comlet Read;
#P inlet 163 84 15 0;
#N comlet Start/stop;
#P inlet 145 84 15 0;
#P window linecount 0;
#P newex 195 85 48 196617 loadbang;
#P toggle 145 225 15 0;
#P window linecount 1;
#P message 195 129 89 196617 replace jongly.aif;
#P message 157 129 43 196617 replace;
#P newex 157 158 112 196617 buffer~ mybuff1 2000;
#P message 300 268 23 196617 0.5;
#P message 300 249 23 196617 1.;
#P flonum 300 287 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 377 335 15 0;
#P message 377 354 68 196617 loopinterp \$1;
#P message 187 315 65 196617 set mybuff2;
#P message 187 375 49 196617 startloop;
#P message 187 349 27 196617 stop;
#P message 228 411 27 196617 stop;
#P message 159 411 65 196617 startwindow;
#P toggle 328 329 15 0;
#P message 328 354 41 196617 loop \$1;
#P flonum 360 384 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 321 384 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 282 444 29 196617 dac~;
#P toggle 282 272 15 0;
#P newex 282 313 27 196617 sig~;
#P newex 282 403 88 196617 groove~ mybuff1;
#B color 5;
#P comment 346 319 81 196617 turn loop on/off;
#P comment 159 299 112 196617 change working buffer;
#P comment 163 225 100 196617 <<<< on/off;
#P newex 157 190 112 196617 buffer~ mybuff2 2000;
#P connect 27 0 25 0;
#P fasten 28 0 23 0 168 114 162 114;
#P connect 23 0 22 0;
#P fasten 24 0 22 0 200 151 162 151;
#P fasten 25 0 12 0 150 386 164 386;
#P fasten 25 0 15 0 150 371 192 371;
#P connect 26 0 24 0;
#P fasten 25 0 6 0 150 253 287 253;
#P connect 6 0 5 0;
#P fasten 19 0 5 0 305 309 287 309;
#P fasten 20 0 5 0 305 311 287 311;
#P fasten 21 0 5 0 305 309 287 309;
#P fasten 17 0 4 0 382 376 287 376;
#P fasten 16 0 4 0 192 340 287 340;
#P fasten 10 0 4 0 333 380 287 380;
#P fasten 14 0 4 0 192 371 287 371;
#P fasten 15 0 4 0 192 396 287 396;
#P connect 5 0 4 0;
#P connect 4 0 7 0;
#P fasten 13 0 7 0 233 439 287 439;
#P fasten 12 0 7 0 164 439 287 439;
#P connect 8 0 4 1;
#P fasten 25 0 11 0 150 313 333 313;
#P connect 11 0 10 0;
#P connect 9 0 4 2;
#P connect 18 0 17 0;
#P connect 30 0 31 0;
#P connect 31 0 33 0;
#P connect 33 0 37 0;
#P connect 4 0 30 0;
#P connect 32 0 30 1;
#P connect 30 0 34 0;
#P connect 34 0 35 0;
#P connect 36 0 29 0;
#P connect 35 0 29 0;
#P connect 34 1 36 0;
#P pop;
#P newobj 426 194 49 196617 p groove;
#P number 487 317 35 9 0 255 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P user uslider 446 273 18 128 255 1 0 0;
#P message 372 399 32 196617 print;
#P newex 446 424 71 196617 serial a 9600;
#P window linecount 3;
#P comment 473 274 100 196617 Slide the fader or use the number box to dim the LED;
#P window linecount 2;
#P comment 229 399 125 196617 Click here to get a list of serial ports;
#P connect 7 0 6 0;
#P connect 9 0 8 0;
#P connect 8 0 4 0;
#P fasten 4 0 2 0 451 422 451 422;
#P fasten 3 0 2 0 377 419 451 419;
#P fasten 5 0 2 0 492 420 451 420;
#P connect 10 0 6 1;
#P connect 6 1 8 1;
#P window clipboard copycount 11;


The Arduino Code

/*
 * Dimmer
 * by David A. Mellis
 *
 * Demonstrates the sending data from the computer to the Arduino board,
 * in this case to control the brightness of an LED.  The data is sent
 * in individual bytes, each of which ranges from 0 to 255.  Arduino
 * reads these bytes and uses them to set the brightness of the LED.
 *
 * http://www.arduino.cc/en/Tutorial/Dimmer
 */
 
int ledPin = 9;

void setup()
{
  // begin the serial communication
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
}

void loop()
{
  byte val;
  
  // check if data has been sent from the computer
  if (Serial.available()) {
    // read the most recent byte (which will be from 0 to 255)
    val = Serial.read();
    // set the brightness of the LED
    analogWrite(ledPin, val);
  }
}

/* Processing code for this example
// Dimmer - sends bytes over a serial port
// by David A. Mellis

import processing.serial.*;

Serial port;

void setup()
{
  size(256, 150);
  
  println("Available serial ports:");
  println(Serial.list());
  
  // Uses the first port in this list (number 0).  Change this to
  // select the port corresponding to your Arduino board.  The last
  // parameter (e.g. 9600) is the speed of the communication.  It
  // has to correspond to the value passed to Serial.begin() in your
  // Arduino sketch.
  port = new Serial(this, Serial.list()[0], 9600);  
  
  // If you know the name of the port used by the Arduino board, you
  // can specify it directly like this.
  //port = new Serial(this, "COM1", 9600);
}

void draw()
{
  // draw a gradient from black to white
  for (int i = 0; i < 256; i++) {
    stroke(i);
    line(i, 0, i, 150);
  }
  
  // write the current X-position of the mouse to the serial port as
  // a single byte
  port.write(mouseX);
}
*/

/* Max/MSP patch for this example

max v2;
#N vpatcher 10 59 610 459;
#P user uslider 286 66 18 128 255 1 0 0;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 212 192 32 196617 print;
#P newex 286 217 71 196617 serial a 9600;
#P window linecount 2;
#P comment 316 148 100 196617 Slide the fader to dim the LED;
#P comment 69 192 125 196617 Click here to get a list of serial ports;
#P fasten 4 0 2 0 291 215 291 215;
#P fasten 3 0 2 0 217 212 291 212;
#P pop;
*/

To cover:

This
That
and the other. 

This also has ramifications concerning:

Life, the universe and anything...





The Task

  • This isn't a task, yet!

  • Do this.
  • Then do that.

Finally

  • Zip or Stuff your patches, demos, etc. into one file called your_student_number_"arduino01" (e.g. 0504335_arduino01.zip or 0504335_arduino01.sit), include a readme with your name and student number and, if necessary, how to use or just open the patch, and submit the whole thing here.

You might also be interested in:


The Projects

The projects and tasks are designed to help you through the various courses and materials that you'll have to deal with, and also to provide an active and practical element to what could otherwise become a rather dry and technical exercise. Tasks are small exercises - you may be asked to complete one or two per week. Projects are larger and carry a higher percentage of the mark. We will undertake two, three, four or more projects and tasks. The final project is usually an individual choice project, and will be worth significantly more than the others in terms of percentages in your portfolio. We will usually try to set aside a time to perform the projects in a public setting.