Dr. Kayarvizhy N Dr. Kayarvizhy N

Internet of Things

Touch Sensor – Buzzer

August 19, 2016All posts

This program make toggle between two frequency based on whether you touched the sensor

Arduino-Capacitive-Touch-Sensor-Tutorial

Connect buzzer’s red wire to Arduino 5v and black wire to GND

#include<NewPing.h>

void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
pinMode(12,OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
 int val=digitalRead(2);
 Serial.println(val);

 if(val==1)
 {
  digitalWrite(12,HIGH);
  tone(9,2000,100);
  
 }
 else
 {
  digitalWrite(12,LOW);
  tone(9,3000,10);
 
 }
 delay(1000);
}

 

0 0 votes
Article Rating
0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Oldest
Newest Most Voted