Arduino Forum

Using Arduino => Introductory Tutorials => Topic started by: rising_youngstars on Aug 01, 2020, 10:20 am

Title: Tutorial | Using a Touch Sensor
Post by: rising_youngstars on Aug 01, 2020, 10:20 am
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  (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 );
     }
}



(https://img.dxcdn.com/productimages/sku_323904_1.jpg)
Title: Re: Tutorial | Using a Touch Sensor
Post by: rising_youngstars on Aug 01, 2020, 11:22 am
Please reply your reviews and do see the video :)
Title: Re: Tutorial | Using a Touch Sensor
Post by: TheMemberFormerlyKnownAsAWOL on Aug 01, 2020, 05:07 pm
...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) );
}
Title: Re: Tutorial | Using a Touch Sensor
Post by: rising_youngstars on Aug 02, 2020, 05:43 am
Yep....
Title: Re: Tutorial | Using a Touch Sensor
Post by: mika_hawkins on Aug 18, 2020, 02:14 pm
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