For fast transaction call 0916.457.0748
Touch Sensitive Switch -- Tutorial

Touch Sensitive Switch -- Tutorial

Want something new about switching. Come and lets get going, Make switching to the next level with Touch Sensor with our favorite Arduino UNO.

Things you'll need:

  • Arduino UNO R3
  • Touch Sensor
  • Buzzer
  • Breadboard
  • Connecting Wire

Schematic Diagram and Actual Material

Connect Signal Pin of Sensor to Digital Pin 11 of Arduino
Vcc to 5V
Gnd to Ground
Connect the positive terminal of the buzzer to Digital Pin 7 of Arduino
Negative to Ground

 

 

 

 

 

 

 

 

 

 

 

 

 

Connect the pins according to the schematic diagram shown above. If you would change any pin designation, make sure to change it also in the code below.

Building the Code

Open your Arduino IDE.

Write the following code below.

int pinSignal = 11;   // assign signal input for the sensor
int value = 0;          // variable to save value from the sensor
int count = 0;         // switching purposes
int buzz = 7;          // buzzer connected to this pin
bool con = false;   // looping purposes

void setup() {


Serial.begin(9600);   // start serial monitor
pinMode(pinSignal,INPUT);   // set pinSignal as input
pinMode(buzz, OUTPUT);   // set buzz as output

}

void loop() {

value = digitalRead(pinSignal);   // read and save the data from the sensor
switching();   // call switching function

}

void switching() {   // we used function for clarity of the code

if (value == 1){   // if the sensor is touch or value equal to 1, does the code below
if(con == false){  // condition so that the same value won't be repeated
con = true;
count++;
if (count == 1){Serial.println("ON"); digitalWrite(buzz, HIGH);} 
delay(100);
if (count == 2){Serial.println("OFF"); count = 0; digitalWrite(buzz, LOW);}
}
} else {con = false;}
delay(100);

}

/*---- http:connectedcities.com.ph ----*/

 

Connect your Arduino Uno and upload the code.

 The program above has only one objective. If you touch the sensor, it will activate the buzzer and if you touch it again, it will then turn off.

You can also use ATmega328P to make your project smaller and easy packaging.

That's all.

Comment below if you want some more amazing and advance tutorials.

Happy Coding!


0 comments

Leave a comment

Please note, comments must be approved before they are published

Payment Methods

Facebook Rewards Program