hello;
I have successfully connected the touch sensor to the arduino but I would like to put a screen that displays the number of times I touch the touch sensor.
can someone please help me ?
hello;
I have successfully connected the touch sensor to the arduino but I would like to put a screen that displays the number of times I touch the touch sensor.
can someone please help me ?
Have you tried the example programs from the LCD library ?
Nope; I'm going to try
Don't try to write the program all in one go. Start small and write portions and test them You say
I have successfully connected the touch sensor to the arduino
You have connected it, but can you read it and display its state on the Serial monitor ?
Can you detect when its state changes ?
What counts as a change of state anyway ?
Maybe take a look at the StateChangeDetection example in the IDE
I have programmed the touch sensor alone and yes; the serial monitor indicates whether or not I touch the touch sensor. However, I have no Idea for the program of my LCD. I want the program to indicate the number of times I find the sensor.
I have no Idea for the program of my LCD.
Try the LCD library examples first
I want the program to indicate the number of times I find the sensor.
Start by adding 1 to a counter when the reading from the sensor changes from not to touched to touched. Did you look at the example to detecting a change of state as I suggested ?
Please post your code that shows the sensor state in the Serial monitor
Ok; thanks I zill see
int ledPin = 13;
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);
}
If you look at the example I suggested you should be able to see how to detect when the sensor state changes from LOW to HIGH. When that occurs add 1 to a counter and print it