Arduino Guru capacitive sensing

    Aug 11 2011 | 2:34 pm
    Hello, is there an arduino master who could help me to adapt one of these code to send his values to max/msp (maxuino) i tried to mix firmata code with them but no luck...
    thank you

    • Aug 12 2011 | 2:22 pm
      Please could you describe your problem in more detail, in particular the circuit you have made.
    • Aug 12 2011 | 2:47 pm I basically need 5 contacts ( each finger) to be a capacitive sensor, in the two links i previously gave, i do think the capsense method would be better as it sounds to have a more bigger and flexible range.
      so the circuit is 5 metal pieces doing capacitive sensing and then 5 digital output turning on 5 different LEds linked to each 5 sensors. contact on sensor 1 turn on LED 1 , etc etc
      but i still need the capacitive sensor values to go into max/msp as i need to control some instrument and samplers with it...
      not sure i make sense, let me know :)
    • Aug 12 2011 | 2:49 pm
      would me be nicer to be able to control the led from max/msp as well.
      cap sensor value ===> firmata in ===> max/msp (instruments) =====> Firmata out ====>LEDs
      sort of..
    • Aug 12 2011 | 3:40 pm
      Hello freeka
      If you don't require Max GUI control of the LEDs, can I suggest a simpler algorithm?
      capSensor ---> Arduino ---> Max
      and just light the LEDs using Arduino code conditions:
      if (capSense1 > "some-minimum-value") { digitalWrite (LedPin1, HIGH); } else { digitalWrite (LedPin1, LOW); }
      I think your first task should be to ensure you're getting clean signals from your circuit; use the serial monitor window in Arduino to check what your circuit and sensors are up to. You should have something like:
      Serial.print (mySensor1); Serial.print ("/t"); Serial.print (mySensor2); Serial.print ("/t"); . . . . Serial.println (mySensor5); }
      at the end of your void loop() function.
      Brendan ps I shouldn't be replying, as I don't meet the OP criteria :p
    • Aug 12 2011 | 8:22 pm
      OP Op!
      i would have prefer to deal with the light from max, then i can change the behavior of them (differents presets , blinking, intensity linked with the sound i trig, etc...)
      but if its easier to do it straight from the arduino then i can go the easy way !
    • Aug 12 2011 | 8:31 pm
      Hi if you want various behaviours from your LEDs, then of course the easier solution would be Max ---> Arduino, especially if, like me, the programming chops aren't too hot!
    • Aug 12 2011 | 8:42 pm
      True M(ei)ster!
      then what would be the best way to mix firmata and the above codes? this is the thing i don't really figure out...
    • Aug 12 2011 | 9:27 pm
      errm, maybe I'm missing something here,but if you have serial data flowing though to Max from your sensors which suggests that your circuit is ok & you are then turning on LEDs from Max where is the problem? Use those inputs on your other stuff too. Surely that is the beauty of Firmata, using (familiar) Max to handle i/o Maybe post appropriate part of your patch
      looks like an interesting project
    • Aug 12 2011 | 9:39 pm
      ok, i will try to explain my problem better,
      -the only way i found to communicate between arduino and max is firmata - then the only way i got to do capacitive sensing with the arduino is using the capsense code or the other one above but then the values i got are only into the arduino monitor , so i do need to add code to send these values to max... this is the part i am stuck with... and then of course i still need to turn on/off the leds
      To be more precise, when i started the project i was using resistance sensing technique which possible to do directly with firmata only (basicaly if someone was touching one of the finger and my skin in same time it was triggering sounds and turning on light) but now the project did change a bit and i need to do the same but with people touching just the monster hand finger and without touching my skin in same . i know i could use pressure sensor instead or even put had a "ground" metal piece on each finger to still use the resistance sensing technique but i still would love to arrive to do it thru capacitive sensing method.
    • Aug 12 2011 | 9:58 pm
      >but then the values i got are only into the arduino monitor
      Are you running the Arduino app at the same time as Max? Because that is not a good idea, only one running application on a serial port at a time it seems.
      From reading your second paragraph I think you may need to play with resistor and capacitor values to achieve the distance sensitivity you desire. Plus get some good earthing in your system.
    • Aug 13 2011 | 6:16 pm
      ok i restart from the begining, as a totally newbie, i think i understood today that the code i linked was already sending values to serial... :) so if i finally understand, having the value in the arduino monitor means i can already have the value in max without changing the code ( and yes without opening the arduino monitoring in same time), am i right? :D
      if its the case, does someone can help me to deal with the serial object into max and convert the value in something i can use?
      toujours merci
    • Aug 13 2011 | 6:32 pm
      ok i got it working with the serial object and that code
      but for some reason i got only 2 pins working (13,12) but i have to plug them in pin 12,11... pin 12 on board send message on pin 13 and pin 11 send message as pin 12... i'm using an arduino mega 2560.
    • Aug 13 2011 | 7:49 pm
      Hi again freeka
      With MaxMSP not running, ie closed, can you send me a screenshot of what the readout of your Arduino serial monitor window is doing? If I'm happy that the above code is running fine then I'll show you how to adapt it, and get your data parsed in Max.
      Use the email address contained on my blog here
    • Aug 14 2011 | 3:41 pm
      if data is flowing in to your computer as you have validated with the Arduino monitor. Shut that down,then run Max & the Firmata max patch, you should be then able to copy the bits you need from the Firmata patch to your project Max patch.
      edit: did I read somewhere about pin weirdness with the Mega? I forget. If you have some pin swapping & thats all thats wrong, do you need to care?
    • Aug 15 2011 | 3:53 pm
      Hi freeka I responded to your email, but my reply appears to have bounced; the email text is below, and posted here as it may help others:
      the second example is a complete mystery to me I'm afraid, so I'll suggest some changes for the 1st one.
      If you are getting changing values for each of your capacitive sensors on pins 8 - 13 then getting them into Max is easy.
      Change the following code snippet:
      for(char i = 0; i < 6; i++) { capval[i] = getcap(pinval[i]); Serial.print("digital "); REMOVE THIS LINE Serial.print(i+8, DEC); REMOVE +8; CHANGE DEC TO BYTE Serial.print(": "); REMOVE THIS LINE Serial.println(capval[i], DEC); CHANGE println TO print; CHANGE DEC TO BYTE } Serial.println(""); REMOVE THIS LINE }
      so that it reads
      for(char i = 0; i < 6; i++) { capval[i] = getcap(pinval[i]); Serial.print(i, BYTE); //each time round the for loop, send the value of i Serial.print(capval[i], BYTE);//followed by that pins value } }
      in Max, you then need a [serial 9600], a [zl group 2] and a [route 58 49 50 51 52 53]; the arguments given here for [route] should be the ascii code numbers for 0, 1, 2, 3, 4, 5 - I'm not 100% sure I've got them right; if you don't know, use the [key] object to check what the correct ascii codes for keys 0 - 5 are.
      This SHOULD work, if everything else (remaining code, circuits etc) is fine. And this is as far as my skills go; I am by no means an Arduino guru - sorry.
    • Aug 15 2011 | 8:45 pm
      Serial.print(i, BYTE);
      The BYTE argument negates the need for ascii conversion, doh! Therefore [route 0, 1, 2, 3, 4, 5) works fine. Without the BYTE suffix [route] WILL need ascii conversion.
    • Aug 18 2011 | 11:00 am
      thanks for your help and time!
      Brendan, your code worked perfect for me!
      i finally kept the resistance sensing for my work, as the capsense code is not a happy latency solution and the capacitive sensing on digital pin don't have a big range...
      here is the result:
      have a gooday
    • Mar 04 2014 | 7:35 pm
      I'm a newbie at Arduino programming and I didn't quite understand what you meant by adding this code. (for(char i = 0; i < 6; i++) ... ) where do i add this?
      but my values seem to be jumping quite high, like in the 10000 and when I'm not touching it, it runs less than 50. Could you advice me on this?