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 Specifications
This module consists of a FZ1713 tactile push button, a 10kΩ resistor and 3 male header pins.
Rating | 50mA 12VC |
Environment temperature | -25°C to 105°C [ -13°F to 221°F] |
Durability | 100,000 cycles |
Operating Force | 180/230(±20gf) |
Board Dimensions | 18.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.
KY-004 | Arduino |
---|---|
S | Pin 3 |
middle | +5V |
– | GND |

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()
{
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);
}
}
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).