Table of Contents
Example Description
Discover how a metal touch sensor works, generating signals upon contact with charged objects. Learn to build a touch-responsive switch circuit using Arduino.
introduction

A metal touch sensor is a type of sensor that generates signals when touched by any charged object. it has a transistor-like element which sensor the external touch on it, based on thee signal generated we can use this sensor as a switch or any other application.

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