Table of Contents

Introduction to Touch Sensors

Example Description
Discover the fascinating world of touch sensors and how they operate based on changes in capacitance caused by static charges from conductive objects.
introduction

Touch sensors are innovative devices that respond to changes in capacitance resulting from static charges generated by conductive objects. Their unique working principle enables them to detect touch interactions, making them ideal for various applications, including touch-sensitive buttons and interactive surfaces.

Circuit

Code

  1. Add an “if” block from the controls palette into the scripting area.
  2. From the Arduino sensor palette, add “read digital sensor () at pin()” inside the “if” block. Choose “touch sensor” from the drop-down menu
  3. Create a variable and name it “count.” Increment the count by 1 inside the “if” block, which helps keep track of touch interactions.
  4. Now use an “if then else” block inside the “if” block to check whether the count variable is even or odd. The modulo (mod) block from the Arduino palette can be utilized for this purpose.
  5. Based on the condition, control the LED to turn it ON for even counts and OFF for odd counts.
  6. Add the “set digital pin () output as ()” block from the Arduino palette within the “if” and “else” blocks, respectively.
  7. Set the “count” variable to 0 at the beginning of the code to ensure accurate counting from the start.
  8. Add a “when flag clicked” block from the events palette to initiate the code execution.

Script

  • Output