Dear community,
I pretend to use this touch sensor to define two states of an installation, a) when touched and b) when not touched. However, after a few seconds the sensors gives a reading of "not touched" when it is still being touched.
Could anybody help me?
thanks
#define ctsPin 8 // Pin for capactitive touch sensor
int ledPin = 10; // pin for the LED
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode(ctsPin, INPUT);
}
void loop() {
int ctsValue = digitalRead(ctsPin);
if (ctsValue == HIGH){
digitalWrite(ledPin, HIGH);
Serial.println("TOUCHED");
}
else{
digitalWrite(ledPin,LOW);
Serial.println("not touched");
}
delay(500);
}
More details about the sensor and the code: