KY-036 Metal-touch sensor module as a momentary switch with Arduino

Metal-touch sensor module

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.

Parts Needed

You need to have the following parts

  • Arduino (Any version)
  • 1x KY-036
  • 1x One-Channel Relay module 5V
  • Jumper Wires

For Arduino

Wiring Metal-touch sensor module

PinWiring KY-036 to Arduino
OUTDigital Pin – 2
GNDGND
VCC5V

Wiring Relay

PinWiring relay to the Arduino
SDIgital Pin – 13
GND
+5V

Schematics For Arduino

Assemble all the parts by following the schematics below:

Connect the light lamp to the relay.

Coding Arduino

// constants won't change. They're used here to set pin numbers:
const int buttonPin = 2;     // the number of the Sensor pin
const int ledPin =  13;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT_PULLUP);
}

void loop() {
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed. If it is, the buttonState is HIGH:
  if (buttonState == HIGH) {
    // turn LED on:
    digitalWrite(ledPin, LOW);
  } else {
    // turn LED off:
    digitalWrite(ledPin, HIGH);
  }
}
  • Upload the code to the Arduino.