Arduino Guru capacitive sensing
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…
Please could you describe your problem in more detail, in particular the circuit you have made.
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 :)
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
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);
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:
at the end of your void loop() function.
ps I shouldn’t be replying, as I don’t meet the OP criteria :p
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 !
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!
then what would be the best way to mix firmata and the above codes?
this is the thing i don’t really figure out…
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
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.
>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.
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?
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.
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
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?
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.
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.
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
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?
I'm using this code to get some values in maxmsp..
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?
Forums > MaxMSP