Capacitive Sensor to Max MSP

    Sep 07 2012 | 5:41 am
    Ok so I am new to max and arduino. I have used a arduino sketch to read pin 2 as a capacitive sensor. the arduino patch is all good, it runs and the numbers display in the serial monitor. How do I get Max to receive the same numbers as the arduino serial monitor? I hope this makes sense, again just started. thanks so much.

    • Sep 07 2012 | 6:59 am
      Have a look at the [serial] object in MaxMSP to send/receive data to/from the USB (serial) port.
    • Sep 07 2012 | 7:33 am
      Hi very briefly, the [serial] object in Max requires three things: a 'port' argument that identifies the COM port number of the Arduino (in Windows, this shows up in your hardware Device Manager); a baud rate argument which matches the Arduino baud rate (visible in the Serial Monitor window), and; a [metro] object to poll the [serial] object. So, I use [serial c 9600] with a [metro] attached at the input - your [serial] arguments may/will differ.
      Depending on which version of Arduino you're using, and which 'sketch' (roll-your-own, or Maxuino etc) you may need to add/change:
      Serial.print(whatever, BYTE); or Serial.write(whatever);
      But there are too many unknowns here: Arduino version, sketch etc etc. Experiment with the Arduino Examples and these patches:
      And unless you read some tutorials, you won't be able to test and adapt your code/patch:
    • Sep 07 2012 | 1:22 pm
      assuming you haven't read any Arduino-to-Max toots, which you may have already done.....
    • Oct 09 2012 | 12:32 pm
      Thanks so much for the replies. I'm not understanding this yet... I can't find the COM port number of the arduino. I think I should have provided more information to start out with. I'm running OSX 10.7.4, Macbook pro, Arduino UNO, Latest version of Arduino software and here is the arduino sketch. I'm using capacitive paint to create a proximity sensor.
      /* * CapitiveSense Library Demo Sketch * Paul Badger 2008 * Slightly adapted by Bare Conductive 2011 * Uses a high value resistor e.g. 10 megohm between send pin and receive pin * Resistor effects sensitivity, experiment with values, 50 kilohm - 50 megohm. Larger resistor values yield larger sensor values. * Receive pin is the sensor pin - try different amounts of Bare Paint * Best results are obtained if sensor foil and wire is covered with an insulator such as paper or plastic sheet */
      CapSense cs_4_2 = CapSense(4,2); // 10 megohm resistor between pins 4 & 2, pin 2 is sensor pin, add Bare Paint // CapSense cs_4_5 = CapSense(4,5); // OPTIONAL: for sensor 2, 10 megohm resistor between pins 4 & 6, pin 6 is sensor pin, add Bare Paint // CapSense cs_4_8 = CapSense(4,8); // OPTIONAL: for sensor 3, 10 megohm resistor between pins 4 & 8, pin 8 is sensor pin, add Bare Paint
      void setup() { cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF); // turn off autocalibrate on channel 1 - just as an example Serial.begin(9600); }
      void loop()
      { long start = millis(); long total1 = cs_4_2.capSense(30); // long total2 = cs_4_5.capSense(30); // OPTIONAL for sensor 2 // long total3 = cs_4_8.capSense(30); // OPTIONAL for sensor 3
      // Serial.print(millis() - start); // OPTIONAL: check on performance in milliseconds // Serial.print(" "); // OPTIONAL: tab character for debug windown spacing
      Serial.println(total1); // OPTIONAL: To use additional sensors,change Serial.println to Serial.print for proper window spacing //Serial.print(" "); // OPTIONAL: tab character for window spacing for sensor output 2 //Serial.print(total2); // OPTIONAL: print sensor output 2 //Serial.print(" "); // OPTIONAL: tab character character for sensor output 3 //Serial.println(total3); // print sensor output 3
      delay(10); // arbitrary delay to limit data to serial port }
      Also provided quick snapshot of max patch
    • Oct 09 2012 | 1:49 pm
      Send the "print" message to the serial object to get a list of the connected serial ports on your computer. Your Arduino may not be connected to port a.
      Increase the speed of your metro. You're only poling the serial port every second, but your arduino is sending information up to 200 times a second.
      Additionally, Max's serial object expects raw bytes (sent by Serial.write() on the Arduino). When you're using Serial.println(), you're sending ASCII encoded information. The float box you have connected to the serial object won't be much help here. Because println also sends a newline/carriage return combo, you can use use [select] and [zl group] to filter the message from the Arduino.
      See below :
    • Oct 09 2012 | 9:14 pm
      Thank you so so so much! It worked perfectly!
    • Feb 25 2015 | 5:20 am
      Send the "print" message to the serial object to get a list of the connected serial ports on your computer.
      When I click the "print" message, Max freezes for about 5 seconds, and nothing appears in the Max window... Any thoughts? I can see from my Parallax Propeller Serial Terminal software that COM 4 is available to connect, so I don't see why a list of at least one open serial port isn't showing up.