KY-004 Key Switch Module

Description

Arduino Key Switch Module Keyes KY-004 is a push button that will output a high signal when pressed.

Specifications

The module consists of a FZ1713 tactile push button switch and a resistor.  Compatible with popular electronics platforms like Arduino, Raspberry Pi and Esp8266.

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

KY-004 Connection Diagram

Connect the power line (middle) and ground to +5V and GND respectively. Connect signal (S) to pin 3 on the arduino.

KY-004Arduino
SPin 3
middle+5V
-GND
Arduino KY-004 connection diagramclick to enlarge

Example Code

The following sketch will turn on Arduino's pin 13 LED when the button on KY-004 is pressed.

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);
	}
}

Leave a Reply

avatar