Contents

Interfacing YwRobot Touch Sensor Module with Arduino

YwRobot Touch Sensor Module Features

Touch Sensor is used to detect human finger touch. It is known as a touch switch as well. These sensors are easy to use and useful in many projects. Before touching the sensor, the output signal is always HIGH. When a human finger touches the sensor, it will generate a LOW level signal. This module also has an LED that lights up when the sensor is touched.

Note

This module works in trigger mode. That is when the sensor is touched, the digital output is LOW and remains LOW until the next touch.

You can download the datasheet of this module here.

YwRobot Touch Sensor Module Pinout

This sensor has 3 pins:

  • VCC: Module power supply – 5 V
  • GND: Ground
  • SIG: Digital output

You can see pinout of this module in the image below.

Required Materials

Hardware Components

Arduino UNO R3 × 1
AYwRobot Toch Sensor × 1
Male to Female jumper wire × 1

Software Apps

Arduino IDE

Interfacing YwRobot Touch Sensor Module with Arduino

Step 1: Circuit

The following circuit shows how you should connect Arduino to YwRobot sensor. Connect wires accordingly.

Step 2: Code

Upload the following code to Arduino. This code displays the sensor’s status in the serial monitor. If you touch the sensor, the phrase “The sensor is touched” appears in the serial monitor.

    /*
  Touch Sensor-YwRobot
  modified on 10 oct 2020
  by Amir Mohamad Shojaee @ Electropeak
  
Home
//Based on arduinogetstarted.com example */ const int SENSOR_PIN = 5; // Variables will change: int lastState = HIGH; int currentState; void setup() { Serial.begin(9600); // initialize the Arduino's pin as aninput pinMode(SENSOR_PIN, INPUT); } void loop() { // read the state of the the input pin: currentState = digitalRead(SENSOR_PIN); if(lastState == HIGH && currentState == LOW) Serial.println("The sensor is touched"); // save the the last state lastState = currentState; }

In the first part of the code, the variables are defined. But the point is that the status of the input signal is constantly measured, and if it changes from HIGH to LOW , it means that the sensor is touched and turned on. If you touch again, the switch turns off and returns to its first state. The output is as follows.

Liked What You See?​
Get Updates And Learn From The Best​

Leave a Reply

Your email address will not be published. Required fields are marked *