j

j

Foto del 413205-09-2456917 alle 00:06.jpg

Which part are you having a problem with? The second sensor, or sending it as a separate MIDI device?

For adding more capacitive sensors, the CapacitiveSensor page in the Arduino Playground has an example sketch with 3 inputs:

http://playground.arduino.cc/Main/CapacitiveSensor?from=Main.CapSense

I took the opportunity to correct a minor spelling error, and change some datatypes to unsigned long to match the millis() datatype and prevent rollover errors.

#include <CapacitiveSensor.h>

/*
 * CapacitiveSense Library Demo Sketch
 * Paul Badger 2008
 * 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 foil/metal on this pin
 * Best results are obtained if sensor foil and wire is covered with an insulator such as paper or plastic sheet
 */


CapacitiveSensor   cs_4_2 = CapacitiveSensor(4,2);        // 10 megohm resistor between pins 4 & 2, pin 2 is sensor pin, add wire, foil
CapacitiveSensor   cs_4_5 = CapacitiveSensor(4,5);        // 10 megohm resistor between pins 4 & 6, pin 6 is sensor pin, add wire, foil
CapacitiveSensor   cs_4_8 = CapacitiveSensor(4,8);        // 10 megohm resistor between pins 4 & 8, pin 8 is sensor pin, add wire, foil

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()                    
{
    unsigned long start = millis();
    unsigned long total1 =  cs_4_2.capacitiveSensor(30);       // Changed datatype to unsigned long to prevent
    unsigned long total2 =  cs_4_5.capacitiveSensor(30);      // rollover errors, as millis() is an unsigned long
    unsigned long total3 =  cs_4_8.capacitiveSensor(30);      // datatype

    Serial.print(millis() - start);        // check on performance in milliseconds
    Serial.print("\t");                    // tab character for debug window spacing

    Serial.print(total1);                  // print sensor output 1
    Serial.print("\t");
    Serial.print(total2);                  // print sensor output 2
    Serial.print("\t");
    Serial.println(total3);                // print sensor output 3

    delay(10);                             // arbitrary delay to limit data to serial port 
}

The second sensor, or sending it as a separate MIDI device?

at this moment just need to put THE SECOND OR THIRD capacitive SENSOR..
I WOULD LIKE TO HAVE MORE than one or more i can have from an ARDUINO uno
after this i'll set the different channel for each capacitiveSensor

i've also tryed to use the analog inputs HERE

CapacitiveSensor capSensor = CapacitiveSensor(A0,A1);

int threshold = 1000;

for example..... and it works
in the next post i'll try the sketch i've made with this and the example sketch of capacitive sensors in order to put more than one sensors, and i'll repost you the result
A question for you ... what happen if instead to turn off the function autocalibrate from void setup i completely remove from the code ? it will work the same ? or the capacitive sensor needs this function to work ?

Thanks@poly