Danny van den Brande
Published © CC BY-SA

Arduino - Touch Sensor Switch Using The KY-036

Hello world! Here we go again! I made another example on one of the sensors I got. This time I made a example for the KY-036.

BeginnerProtip1 hour4,256
Arduino - Touch Sensor Switch Using The KY-036

Things used in this project

Story

Read more

Schematics

Schematic

Code

KY-036_Touch_Sensor_Example.ino

Arduino
In this example we use the KY-036 Touch sensor to turn on a led and buzzer.
/*
Author: Danny van den brande, Arduinosensors.nl. BlueCore Tech.
In this example we use the KY-036 Touch sensor to turn on a led and buzzer.
 */
int GreenLed = 5;
int BlueLed = 6;
int Buzzer = 7;
int TouchSensor = 3; 
int val;

void setup ()
{
pinMode (GreenLed, OUTPUT);
pinMode (BlueLed, OUTPUT);
pinMode (Buzzer, OUTPUT);
pinMode (TouchSensor, INPUT);
}
void loop ()
{
val = digitalRead (TouchSensor) ;
if (val == HIGH) 
{
digitalWrite (BlueLed, HIGH);
digitalWrite (GreenLed, LOW);
digitalWrite (Buzzer, HIGH);
}
else
{
digitalWrite (BlueLed, LOW);
digitalWrite (GreenLed, HIGH);
digitalWrite (Buzzer, LOW);
}
}

Credits

Danny van den Brande

Danny van den Brande

36 projects • 108 followers
"Hello world."

Comments