Capacitive Sensor Slow

Hi.
I am korean. and beginner.

I am programming with Capacitive Sensor Library at Uno board , but it is showing the sensor capacitive values on the serial terminal is very slow.

One sensor code, Response time is 2 millions sec
Two sensor code, Response time is 1.5 sec.
Three sensor code, Response time is 3sec

How can i fix to slow problem…

DIY_Piano.ino (4.51 KB)

  if (total1<=150  &  total2<=150  &  total3<=150 & total4<=150  &  total5<=150  &  total6<=150 &  total7<=150)

& and && are two different operators. One is correct in this context. One is not. You chose the wrong one.

Use micros() and time how long ONE call to the capacitiveSensor() method takes. Then, figure out how long 7 calls take.

I think problem form this code

long total1 = cs_2_3.capacitiveSensor(30);
long total2 = cs_2_4.capacitiveSensor(30);
long total3 = cs_2_5.capacitiveSensor(30);
long total4 = cs_2_6.capacitiveSensor(30);
long total5 = cs_2_7.capacitiveSensor(30);
long total6 = cs_2_8.capacitiveSensor(30);
long total7 = cs_2_9.capacitiveSensor(30);

when i use just one line. Response is very fast . like 2 millions sec

Start by simplifying the code. Remove all the crap not needed for the problem.

Also show both examples of the 1 and multiple sensor setups. And post them like you're supposed to. Have a look at How to use the forum.

Some extra notes:

CapacitiveSensor   cs_2_4 = CapacitiveSensor(2,4);        // 10M resistor between pins 4 & 6, pin 6 is sensor pin, add a wire and or foil

Wrong comments are worse than no comments :wink:

And if you start numbering variables, arrays are the answer :smiley: