Arduino 101: Using a KY-036 metal touch sensor

in #utopian-io7 years ago (edited)

What Will I Learn?

  • You will learn how to use a KY-036 metal touch sensor.
  • You will learn how to integrate the KY-036 metal touch sensor with the arduino uno board.
  • You will learn how to program the arduino uno to make use of the metal touch sensor module.

Requirements

Hardware

  • Arduino Uno

image.png

Image source

  • Metal touch sensor

image.png

Image source

  • LED

image.png

Image source

  • Resistor(220 ohms)

image.png

Image source

  • Breadboard

image.png

Image source

  • Jumper wires

image.png

Image source

  • USB type A to B cable

image.png

Image source

  • Computer

image.png

Image source

Software

  • Arduino Software/ Arduino IDE

Knowledge

  • Basic electronics and programming knowledge

Difficulty

  • Basic

Project description

This is a simple project that utilizes the use of a metal touch sensor with the arduino uno board. The metal touch sensor is connected to the arduino uno board as the input to detect any electrical connectivity (i.e. human body) and the LED is set as the output. Once the sensor is touched by a conducting body, It will trigger the switch then sends that data into the arduino uno board and thus turning the LED on.

Component description

Arduino Uno - is a type of arduino board that is used regularly by specialist and hobbyist because of its robust design. It is equipped with a microcontroller board that is based on ATMega328P with 14 advanced I/O pins (6 are PWM outputs), 6 analog inputs, 16 Mhz quartz crystal, a power jack, a USB port, an ICSP header and a reset button.Reference

KY-036 metal touch sensor - is a type of switch that triggers whenever the metal spike of the sensor is touched by a conducting body like our body. This module has 4 header pins, these are allocated for the +5V, GND, D0 / (Digital Output) , A0 / (Analog Output). Reference

image.png

Image source

Tutorial Contents

Using a KY-036 metal touch sensor

Step 1: Gather the parts

  • You can purchased the components in your nearby electronics shop or order it up online.

image.png

Step 2: Construct the circuit

Connect the Sources

  • Connect the 5 V pin of the arduino uno board into the top/bottom slot of the breadboard. The connections here are horizontally connected making it an ideal for the sources.
  • Connect the GND pin of the arduino uno board into the top/bottom slot of the breadboard but make sure not to place them together as this will short circuit the board and may damage it beyond repair.

image.png

Connect the LED

  • Connect the anode(+) of the LED to a 220 ohm resistor that is connected to pin number 7 of the arduino uno board. This resistor will protect the LED from over supply of current.
  • Connect the cathode(-) of the LED to the common ground.

image.png

Connect the sensor

  • Connect the + pin of the metal touch sensor to the voltage source(+) in the breadboard.
  • Connect the GND pin of the metal touch sensor to the common ground(-) in the breadboard.
  • Connect the D0 (digital pin) of the metal touch sensor to pin number 9 of the arduino uno board.

image.png

Step 3: Programming

  • Connect the Arduino board to your computer by using the usb type a to b cable.

image.png

Image source

  • Once connected, open the arduino IDE and go to Tools > Board: > select Arduino / Genuino Uno.

image.png

  • Copy the code below and paste it into your own sketch in the arduino software.
int ledpin = 7 ; // sets the LED @pin 7
int touchpin = 9; // sets the KY-036 metal touch sensor @pin 9
int value ;         // defines the numeric variables as value
void setup ()
{
  pinMode (touchpin, INPUT) ; // sets the metal touch sensor as INPUT
  pinMode (ledpin, OUTPUT) ; // sets LED as the OUTPUT
}
void loop ()
{
  value = digitalRead (touchpin) ; // reads the value of the touchpin
  if (value == HIGH)      // If the value is HIGH 
  {
    digitalWrite (ledpin, HIGH);   // It will turn the LED ON, indicating that the sensor has been triggered
  }
  else        //otherwise
  {
    digitalWrite (ledpin, LOW);  // LED is turned off if sensor is not triggered
  }
}

This is a very simple code that will just turn the LED on whenever the sensor is triggered. First it defines the pins of the LED and the metal touch sensor, then it defines the numeric variables as value. In the setup command, it sets the touch sensor to be the INPUT while the LED is set to be the OUTPUT. In the loop command, the value is set to read the data from the sensor. If the sensor is touched then the value will be HIGH thus turning on the LED, otherwise it the LED is turned OFF.

  • After typing the codes, click the Verify button to save and compile the sketch. This will also check for any errors in the program.

image.png

  • If no errors is found, click the Upload button to start installing the program into the arduino uno board.

image.png

Step 4: Testing

  • Once the programming is done, remove the arduino uno from the computer and connect it with a battery pack to power up the device.
  • Now touch the base of the transistor with your fingers, this should turn the LED on to indicate that the sensor has been triggered.
  • Remove your finger away from the sensor, this should turn the LED off, indicating that the sensor is not touched.
  • Now try to use a metal wire or plate or something conductive and let it touch the base of the transistor, this should also make the LED turn on because the metal wire is a conductive like our body.

Curriculum

Here are my other Arduino tutorials that you may also like:



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Thank you very much @sedatyildiz 😁

Hey @ted7 I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Suggestions

  • Contribute more often to get higher and higher rewards. I wish to see you often!
  • Work on your followers to increase the votes/rewards. I follow what humans do and my vote is mainly based on that. Good luck!

Get Noticed!

  • Did you know project owners can manually vote with their own voting power or by voting power delegated to their projects? Ask the project owner to review your contributions!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x