Interfacing an LED, a buzzer and TTP223 Capacitive Touch Sensor with Arduino Uno
Components Required:
1. Arduino Uno Board
2. TTP223 Capacitive Touch Sensor
3. LED or Buzzer
4. Breadboard
5. Connecting Wires
Do the connection as follows:
Vcc Pin of TTP223 Capacitive Touch Sensor - Arduino 5V
GND Pin of TTP223 Capacitive Touch Sensor- Arduino GND
LED positive pin - Arduino Digial Pin D13
LED negative pin - Arduino Ground Pin
Source Code:
#define ctsPin 7 // Pin for capactitive touch sensor
int ledPin = 13; // 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);
}
Comments
Post a Comment