Touch Sensor With Arduino

Introduction: Touch Sensor With Arduino

Hi guys in this instructables we will learn how to use touch Sensor withith Arduino and in that way we can provide touch inputs to arduino and that can be used For any kind of output. So using this touch sensor can provide the output which can be controlled by touch inputs.

Step 1: Things You Need

These are following things you need for this instructables :

Arduino uno

Touch sensor

Jumper wires

Breadboard

Step 2: Connections

Connect everything According to the shown schmatics and you'll fine.

Step 3: Code

Please copy the following code and upload it to your arduino Board :

// Henry's Bench
// Capacitive Touch Sensor Tutorial

// When Sig Output is high, touch sensor is being pressed

#define ctsPin 2

// 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);

}

Step 4: Testing the Sensor

After connecting everything together and uploading the code to arduino whenever you will touch the touch sensor the LED on pin 13 will light up and on serial monitor you will get a message as "TOUCHED" and when you are not touching it you will get message "not touched". So have fun using touch Sensor in your arduino Project.

Be the First to Share

    Recommendations

    • Explore Science Challenge

      Explore Science Challenge
    • Arduino Contest

      Arduino Contest
    • Furniture Contest

      Furniture Contest

    2 Comments

    0
    Miss_PE
    Miss_PE

    4 months ago

    What if you want to do the opposite. Have the LED light constantly on and the touch sensor, when touched turn it off? How would you adapt the code?

    0
    audreyobscura
    audreyobscura

    1 year ago

    Thanks for sharing, do you have any photos from your build?