Go Down

Topic: Tutorial | Using a Touch Sensor (Read 576 times) previous topic - next topic

rising_youngstars

Aug 01, 2020, 10:20 am Last Edit: Aug 01, 2020, 10:26 am by rising_youngstars
Hello everyone! I may be a Newbie on the Forum but I have over 1.5 years of experience in Arduino...The Touch Sensor is a sensor which sends a HIGH signal to your Arduino when you touch it or if you have not touched it sends a LOW signal to your digital pin.

I am posting this cause not all people know there is a touch sensor. A touch sensor acts similar to a button...Actually it is basically a button but just that you don't need to press anything just touch the middle of the small sensor.

Check out my new Arduino Tutorial on YouTube :-
https://www.youtube.com/watch?v=BLttdRh2QU4

So the touch sensor has 3 pins - VCC, GND, SIG.

VCC - 5V, 3.3V
GND - Ground Pin
SIG - Any Digital Pin ( using pin 9 in this case )

I feel that this sensor is way easy to connect and work with than a button...

Here, I'm going to turn on an LED when the touch Sensor you know, is touched. The code is same as a button's code :-

Code: [Select]


int touchPin = 9; // Touch Sensor's Pin
int touchState; // The state of the Sensor
int ledPin = 13; // The LED Pin

void setup() {

   pinMode ( ledPin, OUTPUT );
   pinMode ( touchPin, INPUT );

}
void loop() {
   
   touchState = digitalRead ( touchPin );

   if ( touchState == HIGH )
   {
       digitalWrite ( ledPin, HIGH );
    }
    else
    {
       digitalWrite ( ledPin, LOW );
     }
}



Our YouTube Channel - https://www.youtube.com/channel/UCyYiKW8PvELEpDLbdY76C0w :)

rising_youngstars

#1
Aug 01, 2020, 11:22 am Last Edit: Aug 01, 2020, 11:23 am by rising_youngstars
Please reply your reviews and do see the video :)
Our YouTube Channel - https://www.youtube.com/channel/UCyYiKW8PvELEpDLbdY76C0w :)

TheMemberFormerlyKnownAsAWOL

...and if you're not getting paid by the LOC
Code: [Select]
const byte touchPin = 9;
const byte ledPin = LED_BUILTIN;

void setup()
{
   pinMode ( ledPin, OUTPUT );
   pinMode ( touchPin, INPUT );
}
void loop()
{
  digitalWrite ( ledPin, digitalRead (touchPin) );
}
Please don't PM technical questions - post them on the forum, then everyone benefits/suffers equally

rising_youngstars

Our YouTube Channel - https://www.youtube.com/channel/UCyYiKW8PvELEpDLbdY76C0w :)

mika_hawkins

Hi,

As a student I genuinely need such a hints. I am starting my outing with Arduino and posts like this will help me starting so Thank you for this great post.

Regards,
Mika Hawkins

Go Up