Interfacing KY-004 Key Switch Module with Arduino

Introduction

In this tutorial, we are going to Interfacing KY-004 Key Switch Module with Arduino, The KY-004 Key Switch Module is a push button that will close the circuit when someone pressed it, sending a high signal to activate the led or another type of load.

This module is compatible to interface with popular electronic platforms like Arduino, ESP32, Raspberry Pi, and other microcontrollers. On pressing the button it gives a high signal to activate the circuit.

KY-004-Key-Switch-Module-with-arduino

Hardware Required

You will require the following Hardware Components for the Interfacing KY-004 Key Switch Module with Arduino

Components#Buy From Amazon
Arduino UNO1Buy Link
KY-004 Key Switch Module1Buy Link
LED ( Red )1Buy Link
Jumper WiresBuy Link
Breadboard1Buy Link

Specifications

This module contains a 10kΩ resistor, an FZ1713 tactile push button, and 3 male header pins.

Rating50mA 12VC
Environment temperature-25°C to 105°C [ -13°F to 221°F]
Durability100,000 cycles
Operating Force180/230(±20gf)
Board Dimensions18.5mm x 15mm [0.728in x 0.591in]

Pinout

Pin Configuration

Pin NamePin Type
SSignal Pin
middle PinVcc (+5)
( – )Ground

Circuit Diagram

The following circuit shows you the connection of the Interfacing KY-004 Key Switch Module with Arduino Please make the connection carefully

KY-004-Key-Switch-Module-with-Arduino-circuit-diagram

Circuit Connections

Place the module on the Breadboard and connect the power pin (middle) and ground (-) of the module to +5V and GND of the arduino. and then connect the signal pin (S) to pin 3 of the Arduino respectively

ArduinoKY-003 ModuleLED
+5vMiddle
GNDGNDLED -Ve
Pin 3Signal
Pin 13LED +Ve

Installing Arduino IDE Software

First, you will require to Download the updated version of Arduino IDE Software and Install it on your PC or laptop. if you Learn How to install the Arduino step-by-step guide then click on how to install Arduino Button given Blow

Code

The following Arduino code will constantly read the button condition on the module, when someone pressed the button it will send a HIGH signal which will turn on the LED placed on pin 13 of arduino

int led = 13; //Define the LED pin
int buttonpin = 3; //Define the push button pin
int val; //Define a numeric variable
void setup()
{
	pinMode(led,OUTPUT);
	pinMode(buttonpin,INPUT);
}
void loop()
{
	val = digitalRead(buttonpin); // check the state of the button
	if(val==HIGH) // if button is pressed, turn LED on
	{
		digitalWrite(led,HIGH);
	}
	else
	{
		digitalWrite(led,LOW);
	}
}

Applications

  1. Security Systems: The module can be integrated into security systems to act as an input device for arming or disarming alarms.
  2. Access Control: It is utilized in access control systems to grant or deny access to specific areas or devices.
  3. Home Automation: The KY-004 module can be used as a trigger for controlling smart home devices or appliances.
  4. Data Input: In data logging projects, the module functions as an input device to record events or data.
  5. Interactive Projects: It is employed in interactive installations or art projects to initiate actions based on user input.

Leave a Comment


error: