Arduino Key Switch Module Keyes KY-004 is a push button that will output a high signal when pressed. The module consists of a FZ1713 tactile push button switch and a resistor. Compatible with popular electronics platforms like Arduino, Raspberry Pi and Esp8266.
Arduino Connections with Push Button Module
Sensor Signal (S) = [Pin 3]
Sensor +V = [Pin 5V]
Sensor – = [Pin GND]
Arduino Code for Push button Module
int Led = 13 ;// Declaration of the LED-output pin
int Key = 3; // Declaration of the sensor input pin
int val; // Temporary variable
void setup ()
pinMode (Led, OUTPUT) ; // Initialization output pin
pinMode (Key, INPUT_PULLUP) ; // Initialization Key pin with internal pull-up resistor
void loop ()
val = digitalRead (Key) ; // The current signal at the key will be read
if (val == HIGH) // If a signal was detected, the LED will light up.
digitalWrite (Led, HIGH);
digitalWrite (Led, LOW);
This example will light up a LED after the button is pressed. On-board LED 13 is used for demo.