Thank you so much for your reply, but I started initially using the digital input approach you suggested me, but I had the same problem: wrong signals from arduino that told me that the switch was closed even if it was not closed! that this is the initial version of the function I had for the digital input:
float Verifica_Touch(int pin_verifica)
{
long i;
float valore=0;
for (i=0; i < 20; i++)
{
int valore_appoggio= digitalRead(pin_verifica);
delay(1);
valore+= valore_appoggio;
}
i=0;
return (valore / 20.00);
valore=0;
}
I inserted several reading operations to smooth the value but it didn't help, So I am tryng with the analog pins.
The thing that screw me up is that if I use a multimeter to measure the potential at the ends of the switch I have exactly zero OR 5 Volt, nothing in the middle, and I also noticed that if I measure the potential between the ground pin and the analog pin of arduino I have more or less 0.6 volts, but as I already told I am a very noob in electronics ![]()
This is the version of the code using the analog Pin
float Verifica_Touch(int pin_verifica)
{
int i;
long valore_sommato=0;
int volte=35;
long prodotto=0L;
long voltaggio=1022L;
prodotto=voltaggio*volte;
// Serial.println(prodotto);
float valore=0;
for (i=0; i < volte; i++)
{
int valore_letto= analogRead(pin_verifica);
//Serial.print("valore letto " );
//Serial.println(valore_letto);
delay(10); // DA VERIFICARREEEEEE!!!!
//Serial.println(i);
valore_sommato+= valore_letto;
}
i=0;
//Serial.print("valore_sommato ");
//Serial.println(valore_sommato);
return (float(valore_sommato) / float(prodotto) );
valore=0;
valore_sommato=0;
}