Problem with using <CapacitiveSensor.h> library

Hello,
i build this small can controlled speaker with capacitive sensor library.
I think there might be a problem with length of jumpers. The jumpers that are going from the cans are about 40-50cm. And the jumpers from arduino are 20cm long. Picture of project is included and the code is written bellow.
End of cables attached to cans are stripped and taped to the side of cans.
It sometimes works when i put my hand over a few cans, but it only beeps after a few moments like once or twice. Thanks for any advice or solution.

Code:


#include <CapacitiveSensor.h>
#define DELAY 15

int buzzer = A3;

const int C = 261;
const int D = 294;
const int E = 329;
const int F = 349;
const int G = 392;
const int A = 440;
const int H = 493;
const int C1 = 523;

CapacitiveSensor c = CapacitiveSensor(0,1);
CapacitiveSensor d = CapacitiveSensor(2,3);
CapacitiveSensor e = CapacitiveSensor(4,5);
CapacitiveSensor f = CapacitiveSensor(6,7);
CapacitiveSensor g = CapacitiveSensor(7,9);
CapacitiveSensor a = CapacitiveSensor(10,11);
CapacitiveSensor h = CapacitiveSensor(12,13);
CapacitiveSensor c1 = CapacitiveSensor(A1,A0);

long value_c;
long value_d;
long value_e;
long value_f;
long value_g;
long value_a;
long value_h;
long value_c1;

void setup()
{
pinMode(buzzer, OUTPUT);
digitalWrite(buzzer, LOW);
pinMode(A5, OUTPUT);
digitalWrite(A5, LOW);
}

void loop()
{
long tone_c = c.capacitiveSensor(30);
long tone_d = d.capacitiveSensor(30);
long tone_e = e.capacitiveSensor(30);
long tone_f = f.capacitiveSensor(30);
long tone_g = g.capacitiveSensor(30);
long tone_a = a.capacitiveSensor(30);
long tone_h = h.capacitiveSensor(30);
long tone_c1 = c1.capacitiveSensor(30);

//play C
if (value_c != tone_c)
{
value_c = tone_c;

if (value_c > DELAY)
{
tone(buzzer, C);
delay(50);
noTone(buzzer);
}
}

//play D
if (value_d != tone_d)
{
value_d = tone_d;

if (value_d > DELAY)
{
tone(buzzer, D);
delay(50);
noTone(buzzer);
}
}

//play E
if (value_e != tone_e)
{
value_e = tone_e;

if (value_e > DELAY)
{
tone(buzzer, E);
delay(50);
noTone(buzzer);
}
}

//play F
if (value_f != tone_f)
{
value_f = tone_f;

if (value_f > DELAY)
{
tone(buzzer, F);
delay(50);
noTone(buzzer);
}
}

//play G
if (value_g != tone_g)
{
value_g = tone_g;

if (value_g > DELAY)
{
tone(buzzer, G);
delay(50);
noTone(buzzer);
}
}

//play A
if (value_a != tone_a)
{
value_a = tone_a;

if (value_a > DELAY)
{
tone(buzzer, A);
delay(50);
noTone(buzzer);
}
}

//play H
if (value_h != tone_h)
{
value_h = tone_h;

if (value_h > DELAY)
{
tone(buzzer, H);
delay(50);
noTone(buzzer);
}
}

//play C
if (value_c1 != tone_c1)
{
value_c1 = tone_c1;

if (value_c1 > DELAY)
{
tone(buzzer, C1);
delay(50);
noTone(buzzer);
}
}
}

End of cables attached to cans are stripped and taped to the side of cans.

Do you think that THAT is ensuring good electrical contact? I don't.

How do the blocks of code differ for each sensor? ONE function with 8 calls, NOT 8 blocks of nearly identical code. You'll have noticed that there is one tone() function, regardless of which note you want to play, not a different function for each note. You should write code the same way.

https://playground.arduino.cc/Main/CapacitiveSensor

"Here are some guidelines for resistors but be sure to experiment for a desired response.
Use a 1 megohm resistor (or less maybe) for absolute touch to activate.
With a 10 megohm resistor the sensor will start to respond 4-6 inches away.
With a 40 megohm resistor the sensor will start to respond 12-24 inches away"

I think that means your 10k resistors are way too low.