Categories

Arduino and touch button

Arduino touch button

Quick start guide presented how to connect an Arduino and a touch button.

 

In this example we used the following elements:

 

Connect the module to Arduino:

For operation of the module using Arduino, you should connect the layout as follows:

 

ModulePin Arduino
GNDGND
OUT2
VCC5 V

 

 

 

Diagram of connecting the module to Arduino Uno.

 

Program for Arduino

Output the default output generates a high status. Identifying the touch causes its transition into a low state. In the example, we used the following code:

int sensor = 2; //pin 2 is connected to the signal czujnikia 

void setup() { 
 Serial.begin(9600); //initialize serial monitor 
 pinMode(sensor, INPUT); //setting Arduino pin as an input 
 pinMode(13, OUTPUT); //pin 13 as output 

 Serial.println ("---- TEST TOUCH BUTTON ----"); 
} 

void loop() { 
 int war = digitalRead(sensor); //read the value from the sensor 
 if (war == LOW) //display information on the serial monitor 
 { //status low means that the detection of the touch, the high status - it is not 
 Serial.println(" Detected touch"); 
 digitalWrite(13, HIGH); //also, in case of detection of touching, the led underneath lights up pin 13 
 } 
 else 
 { Serial.println("Free"); 
 digitalWrite(13, LOW); 
 } 
 delay(200); //delay between consecutive readings 
} 

 

The program displays messages on the display consistent. In addition, when detecting the touch, the led on the module and this in Arduino from under the pin 13 lights up. The effects of the program can be seen in the following screenshot:

 

 

A screenshot of the serial monitor.