rhoadley.net   music   research   courses   software   blogs

ARU    Seminars    Comp&Imp    NMP    CMC2a    CBHH
Sensor Technology    Sonic Art    Major Project    MA Resources


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

sTech Resources:     Home     Blog     Forum     Examples     Projects     Tasks     Tutorials


Sensor Technology Tasks

Arduino, MaxMSP and SuperCollider

Task 3 Name: Arduino, MaxMSP and SuperCollider Set: w4i Due: Thursday 16th December 2010 Weighting: 10% Courses: stech
Prev Task: Vibrating a Piezo Next Task: Arduino, Sensors and Music
Task Summary All stech tasks

To cover:




 

Connecting Arduino and Max

Please see here for the latest versions of these patches, as well as other methods of communicating.


Connecting Arduino and Supercollider

NB In order to use it you must install the Arduino quark. Evaluate the following to see if it's already there:
Quarks.gui;
If not, you should be able to install it with an internet connection and the following:
Quarks.update("arduino"); Quarks.install("arduino");
After installation you'll need to recompile the Library (command-k).
See the Quarks helpfile for more information.


Really Simple SC Example

Arduino Code


/*
  Analog input

 reads an analog input on analog in 0, prints the value out.

 created 24 March 2006
 by Tom Igoe
 */

int analogValue = 0;    // variable to hold the analog value

void setup() {
  // open the serial port at 115200 bps:
  Serial.begin(115200);
}

void loop() {
  // read the analog input on pin 0:
  analogValue = analogRead(0);

  Serial.println(analogValue);       // print as an ASCII-encoded decimal
  
  // delay 10 milliseconds before the next reading:
  delay(10);
}

SC Code


// change the serial port identifier...
p = ArduinoSMS("/dev/tty.usbserial-A9007KNG", 115200);
p.action = { |... msg| msg.postln };
p.close; // close just the port you've just opened
SerialPort.closeAll; // close all ports.

MaxMSP

Use the patch above.

Arduino Code for Sending more than one value...

Then you can read the results as an array in SC. In Max you should see two values on Analog ins 1 and 3 - the second value is the comma!


int analogValue0 = 0;    // variable to hold the analog value
int analogValue1 = 0;

void setup() {
  Serial.begin(115200);
}

void loop() {
  analogValue0 = analogRead(0);
  analogValue1 = analogRead(1);

  Serial.print(analogValue0);
  Serial.print(", ");
  Serial.println(analogValue1);
  
  delay(10);
}





Sending messages to the Arduino

See the next task for this functionality.



Arduino and Breadboards

If you attempted to use two controllers with one board it will have occurred to you that you don't really have enough holes. If this is the case, then you'll want to use a breadboard.





to top of page The Task

  • Make sure you've downloaded and experimented with the above and sorted out a connection between a fairly simple controller on your Arduino (say, a potentiometer) and MaxMSP.
  • Choose a relatively simple opcode/patch to operate and provide a simple demonstration of the board working with the software, (for instance, control the frequency of a ~cycle object).
  • Also demonstrate use of a breadboard to connect the controller to the Arduino.

  • Clearly, I don't want you to submit your Arduinos. That means you need to submit some documentary evidence that you've completed your task. The most obvious way to do this is to submit some sort of video of your task working. If you can't do this, take photos. Bear in mind that you'll get extra marks for 'added value', so try to adapt and make more interesting your files. Simply repeating what we've already done will get minimal marks.
  • Alternatively, You might want to have a go at constructing a simple MIDI Interface. Have a look here. You can do this instead.

  • Added value
    By completing the details of the task you will achieve at least a pass mark. By imaginatively and creatively considering how you might implement the task originally you can add value to your submission, and this added value may increase your mark significantly. Even when making videos of short demonstration tasks try to consider musical and performance criteria.

    What to submit
  • Clearly, I don't want you to submit your Arduinos. That means you need to submit some documentary evidence that you've completed your task. The most obvious way to do this is to submit some sort of video of your task working, as well as of the code running. If you can't do this, take photos.

  • Media files
    You must submit media files, such as video, audio or image files, but please ensure that video files are compressed to a reasonable degree. You should never submit dv files, but compress these to mp4. You should submit no file that is greater in size than 25MB/minute.

  • Compress (zip) your patches, demos, etc. into one file called your_student_number_"arduino_max_sc" (e.g. 0504335_arduino_max_sc.zip), include a readme with your name and student number and, if necessary, how to use or just open the patch.

  • Submit a copy of the files to the i-Centre by 17:00 on Thursday 15th December 2011

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.