Buzzer Alarm using Touch Sensor
Buzzer Alarm using Touch Sensor
Just Arduino Things | TW TechieTube
Create a Buzzer Alarm using Touch Sensor.
Principle:
The capacitance between the touch plate and the Ground plate is sensed and the value is known as the touch sensors value. The Principle behind this Sensors working is based on the body's capacitance.
Components Required:
- Arduino UNO (1)
- Capacitive Touch Sensor (1)
- Breadboard (As per Requirement)
- Jumper Cables (As per Requirement)
- Arduino Bus Cable (1)
Construction:
A Simple project to sense the touch using the Capacitive Touch Sensor.
Now connect the Sensors pins with the order given,
Vcc - Arduino 5v/3.3v Pin
Gnd - Arduino Gnd Pin
Data - Any Digital Pins except D1/D2 on UNO.
Incl. an LED/Buzzer in D13 and Gnd for external value.
As explained in the Video, the Code is written as Follows.
Code:
const int TOUCH_SENSOR_PIN = 8; // Arduino pin connected to the OUTPUT pin of touch sensor
const int LED_PIN = 13; // Arduino pin connected to LED's pin
void setup() {
Serial.begin(9600); // initialize serial
pinMode(TOUCH_SENSOR_PIN, INPUT); // set arduino pin to input mode
pinMode(LED_PIN, OUTPUT); // set arduino pin to output mode
}
void loop() {
int touchState = digitalRead(TOUCH_SENSOR_PIN); // read new state
if (touchState == HIGH) {
Serial.println("The sensor is being touched");;
digitalWrite(LED_PIN, HIGH); // turn on
}
else
if (touchState == LOW) {
Serial.println("The sensor is untouched");
digitalWrite(LED_PIN, LOW); // turn off
}
}
Comments
Post a Comment