The KY-004 Module is an FZ1713 tactile push button key switch that will close the circuit when pressed, sending a high signal to a microcontroller like Arduino, Raspberry Pi and ESP32.
Here, you will get detailed information about this key switch module circuit board, like specifications, pinout, circuit & connection diagram, and how to interface with Arduino.
KY-004 Module Specifications
- Type: Push Button Key Switch
- Max Operating Force: 180/230(±20gf)
- Durability: 100,000 cycles
- Operating Voltage: 3.0V to 5.5V
- Temperature Measurement Range: -55°C to 125°C
- Measurement Accuracy: ±0.5°C
- Board Dimantions: 18.5mm x 15mm
KY-004 Module Pinout
The switch module has 3 male header pins those are -
- Pin (S): Signal
- Pin (Middle): +5V
- Pin (-): GND
KY-004 Module Circuit Diagram
Schematic of the ky-004 key switch module circuit is shown below.
KY-004 Module Interfacing with Arduino
Connection diagram of the KY-004 key switch module with an Arduino is shown below.
Connect the power pin (middle) and ground pin (-) of the ky-004 module to +5V and GND on the Arduino, respectively. The module signal pin (s) connect to digital pin 3 on the Arduino.
Arduino Source Code
The following Arduino sketch for the KY-004 Key Switch Module.
Set the LED on Arduino pin 13 as the output and the signal pin of the KY-004 module as the input. Using this interface, when the button is pressed, the module will send a high signal to the Arduino, which will turn on the LED.
int led = 13; // Define LED on Arduino interface
int signal = 3; // Define KY-004 module interface
int val; // Define a numeric (boolean) variable val
void setup()
{
pinMode(led,OUTPUT); // Set Arduino LED pin as output
pinMode(signal,INPUT); // Set KY-004 module signal pin as input
}
// Start the main program loop
void loop()
{
val = digitalRead(signal); // Read the KY-004 key switch module
if(val==HIGH) // If the button is pressed, turn LED ON
{
digitalWrite(led,HIGH);
}
else
{
digitalWrite(led,LOW);
}
}
No comments
If you have any doubts or questions, please let me know. Don't add links as it goes to spam. Share your valuable feedback. Thanks