Lesson 26 Metal Touch Sensor

Share for us

Introduction

A metal touch sensor is a type of switch that only operates when it’s touched by a charged body. It has a high-frequency transistor which can conduct electricity when receiving electromagnetic signals.

Components

– 1 * SunFounder Uno board

– 1 * USB data cable

– 1 * Metal touch sensor module

– Several jumper wires

Experimental Principle

In this experiment, touch the base electrode of a transistor with fingers to make it conduct electricity, for human body itself is a kind of conductor and an antenna that can receive electromagnetic waves in the air. These electromagnetic wave signals collected by human body are amplified by the transistor and processed by the comparator on the module to output steady signals.

With the LED attached to pin 13 of Uno, connect pin D0 of the sensor to D7 of the Uno board. When the metal touch sensor detects touch signals, the LED will be on. Otherwise, it will be off.

Experimental Procedures

Step 1: Build the circuit

                             Metal Touch Sensor                      SunFounder Uno

                                         AO ——————————————- A0

                                         G  ——————————————– GND

                                          + ——————————————– 5V

                                         D0 ——————————————- D7

Step 2: Program (Please refer to the example code in LEARN -> Get Tutorial on our website)

Step 3: Compile

Step 4: Upload the sketch to SunFounder Uno

Now, touch the base electrode of the transistor and the LED attached to pin 13 on the SunFounder Uno board will light up.

Code

const int SensorPin=7;//const int SensorPin=7;//Level input ports
const int analogIn = A0;
const int ledPin = 13;int SensorState=0;
int analogVal = 0;void setup()
{
pinMode(SensorPin,INPUT);
pinMode(ledPin,OUTPUT);
}void loop()
{
analogVal = analogRead(analogIn);
SensorState=digitalRead(SensorPin);
if(SensorState==HIGH)
{
digitalWrite(ledPin,HIGH);
}
else
{
digitalWrite(ledPin,LOW);
}
}
const int analogIn = A0;
const int ledPin = 13;int SensorState=0;
int analogVal = 0;void setup()
{
pinMode(SensorPin,INPUT);
pinMode(ledPin,OUTPUT);
}void loop()
{
analogVal = analogRead(analogIn);
SensorState=digitalRead(SensorPin);
if(SensorState==HIGH)
{
digitalWrite(ledPin,HIGH);
}
else
{
digitalWrite(ledPin,LOW);
}
}