I wanted to make two capacitive sensors that work individually, in one board.
The problem is that the sensors don't work individually, but commutatively!
Here's the codes and the diagram for understanding.
#include <CapacitiveSensor.h>
CapacitiveSensor cs_4_2 = CapacitiveSensor(4,2);
CapacitiveSensor cs_12_13 = CapacitiveSensor(6,2);
void setup() {
cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF);
cs_12_13.set_CS_AutocaL_Millis(0xFFFFFFFF);
Serial.begin(9600);
}
void loop() {
long start = millis();
long total1 = cs_4_2.capacitiveSensor(30);
long total2 = cs_12_13.capacitiveSensor(30);
Serial.println(millis() - start);
Serial.print("\t");
Serial.println(total1);
Serial.print("\t");
Serial.println(total2);
delay(20);
}
(The pushbutton part is the sensor I connected.)
If I touch sensor 1(D13,D12), the sensors don't work, it seems that the sensors don't work, and always '-2' is checked on sensor 1. Both numbers get lower.
If I touch sensor 2(D4,D2), the sensors work too actively, compared to when I only connected one sensor.
I don't know whether it's a matter of the circuit or the codes...
