KY-004 Key Switch Module

The KY-004 Key Switch Module is a push button that will close the circuit when pressed, sending a high signal.

This module is compatible with Arduino, Raspberry Pi, ESP32 and other platforms.

KY-004 Fritzing custom part image
KEYES KY-004 Key switch module for arduino

KY-004 Specifications

This module consists of a FZ1713 tactile push button, a 10kΩ resistor 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]

Connection Diagram

Connect the module signal pin (S) to pin 3 on the Arduino.

Then connect the board power pin (middle) and ground (-) to +5V and GND on the Arduino respectively.

SPin 3
Arduino KY-004 connection diagram

KY-004 Arduino Code

The following Arduino sketch will continually read the button state on the module, when the button is pressed it will send a HIGH signal that will turn on the Arduino’s LED on pin 13.

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


Leave a Comment

1 thought on “KY-004 Key Switch Module”

  1. I’ve just tested this module out and it seems that the KY004 Module constantly send a HIGH signal that interrupt only when pressed. Meaning the displayed code example is incorrect and the condition should be if(val==LOW).