Hello everyone,
I want to use CapacitiveSensor library in order to make my own aluminum keys piano. I have seen many videos online showing projects like the one I'm trying to do, but for some reason mine doesn't work.
Here's my cuircit:
Here's my code:
#include <CapacitiveSensor.h>
CapacitiveSensor cs_7_6 = CapacitiveSensor(7,6); // 10M resistor between pins 4 & 2, pin 2 is sensor pin, add a wire and or foil if desired
void setup()
{
//cs_7_6.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_7_6.capacitiveSensor(5);
Serial.print(millis() - start); // check on performance in milliseconds
Serial.print("\t"); // tab character for debug windown spacing
Serial.print(total1); // print sensor output 1
Serial.println("\t");
delay(10); // arbitrary delay to limit data to serial port
}
This happens whenever I touch the aluminum foil:
First nothing happens (for ~1 sec), then it prints -2 as the capacity value, and when I release my finger from the foil it prints a very high value.
Anyone knows the reason for it? I'm searching for an answer for a long time and still can't find a solution...
Thanks!
Dan