Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Component Documentation

How to Use KY-004 Key Switch Module: Examples, Pinouts, and Specs

Image of KY-004 Key Switch Module
Cirkit Designer LogoDesign with KY-004 Key Switch Module in Cirkit Designer

Introduction

The KY-004 Key Switch Module is a compact and versatile input device that integrates a tactile pushbutton switch. It is widely used in electronics projects for user input, allowing for simple on/off control. This module is particularly popular in hobbyist projects, including those involving microcontrollers like the Arduino UNO.

Explore Projects Built with KY-004 Key Switch Module

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Arduino UNO Controlled GSM Interface with LCD Feedback and Relay Switching
Image of pascal_issac project: A project utilizing KY-004 Key Switch Module in a practical application
This circuit features an Arduino UNO microcontroller interfaced with a variety of components. It controls a KY-019 relay module to switch power to a motor and communicates with a SIM800L module for cellular connectivity. User inputs are handled via a membrane matrix keypad and pushbuttons, and feedback is provided through an I2C-connected LCD display. A step-up boost converter adjusts voltage from a 12V battery to power the motor, and a 3-position switch is used for additional control.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino Nano Joystick-Controlled Bluetooth Module with Battery Power
Image of padelpro transmitter: A project utilizing KY-004 Key Switch Module in a practical application
This circuit is a wireless joystick controller that uses an Arduino Nano to read analog signals from a KY-023 Dual Axis Joystick Module and transmits the data via an HC-05 Bluetooth Module. The system is powered by a 18650 Li-Ion battery with a rocker switch for power control.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino UNO-Based Smart Humidifier and Temperature Monitor with OLED Display
Image of Humidity Control: A project utilizing KY-004 Key Switch Module in a practical application
This circuit is a smart environmental monitoring and control system. It uses an Arduino UNO to read data from a temperature-humidity sensor and a real-time clock, displays information on an OLED screen, and controls an exhaust fan and a humidifier via a relay module. The system is powered by a 5V power supply and includes a key switch for user input.
Cirkit Designer LogoOpen Project in Cirkit Designer
Wireless Joystick-Controlled Interface with Arduino Nano and NRF24L01
Image of Transmitter 11: A project utilizing KY-004 Key Switch Module in a practical application
This circuit features an Arduino Nano interfaced with a KY-023 Dual Axis Joystick Module for analog input, and an NRF24L01 module for wireless communication. The joystick provides x and y-axis control signals to the Arduino's analog inputs and a switch signal to a digital input, while the NRF24L01 enables the Arduino to communicate with other devices wirelessly. The 2x 18650 batteries supply power to the Arduino, which in turn powers the joystick and the NRF24L01 module.
Cirkit Designer LogoOpen Project in Cirkit Designer

Explore Projects Built with KY-004 Key Switch Module

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of pascal_issac project: A project utilizing KY-004 Key Switch Module in a practical application
Arduino UNO Controlled GSM Interface with LCD Feedback and Relay Switching
This circuit features an Arduino UNO microcontroller interfaced with a variety of components. It controls a KY-019 relay module to switch power to a motor and communicates with a SIM800L module for cellular connectivity. User inputs are handled via a membrane matrix keypad and pushbuttons, and feedback is provided through an I2C-connected LCD display. A step-up boost converter adjusts voltage from a 12V battery to power the motor, and a 3-position switch is used for additional control.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of padelpro transmitter: A project utilizing KY-004 Key Switch Module in a practical application
Arduino Nano Joystick-Controlled Bluetooth Module with Battery Power
This circuit is a wireless joystick controller that uses an Arduino Nano to read analog signals from a KY-023 Dual Axis Joystick Module and transmits the data via an HC-05 Bluetooth Module. The system is powered by a 18650 Li-Ion battery with a rocker switch for power control.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of Humidity Control: A project utilizing KY-004 Key Switch Module in a practical application
Arduino UNO-Based Smart Humidifier and Temperature Monitor with OLED Display
This circuit is a smart environmental monitoring and control system. It uses an Arduino UNO to read data from a temperature-humidity sensor and a real-time clock, displays information on an OLED screen, and controls an exhaust fan and a humidifier via a relay module. The system is powered by a 5V power supply and includes a key switch for user input.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of Transmitter 11: A project utilizing KY-004 Key Switch Module in a practical application
Wireless Joystick-Controlled Interface with Arduino Nano and NRF24L01
This circuit features an Arduino Nano interfaced with a KY-023 Dual Axis Joystick Module for analog input, and an NRF24L01 module for wireless communication. The joystick provides x and y-axis control signals to the Arduino's analog inputs and a switch signal to a digital input, while the NRF24L01 enables the Arduino to communicate with other devices wirelessly. The 2x 18650 batteries supply power to the Arduino, which in turn powers the joystick and the NRF24L01 module.
Cirkit Designer LogoOpen Project in Cirkit Designer

Common Applications and Use Cases

  • User interfaces for electronic devices
  • Input control for microcontroller projects
  • Prototyping and educational tools for learning electronics
  • Interactive installations and exhibits

Technical Specifications

Key Technical Details

  • Operating Voltage: 3.3V to 5V
  • Output Type: Digital signal
  • Contact Type: Normally open

Pin Configuration and Descriptions

Pin Number Description
1 Signal (S)
2 Ground (GND)
3 Voltage Supply (V)

Usage Instructions

How to Use the Component in a Circuit

  1. Connect the V pin to the 3.3V or 5V power supply of your microcontroller or power source.
  2. Connect the GND pin to the ground of your power source or microcontroller.
  3. Connect the S pin to a digital input pin on your microcontroller.

Important Considerations and Best Practices

  • Use a pull-up or pull-down resistor to ensure a stable signal when the switch is open.
  • Debounce the switch in software to prevent false triggering from mechanical vibrations.
  • Avoid applying voltage higher than the recommended operating voltage to prevent damage.

Example Code for Arduino UNO

// Define the pin connected to the KY-004 module
const int buttonPin = 2; 

// Variable for storing the button state
int buttonState = 0; 

void setup() {
  // Initialize the button pin as an input
  pinMode(buttonPin, INPUT);
}

void loop() {
  // Read the state of the button
  buttonState = digitalRead(buttonPin);

  // Check if the button is pressed
  if (buttonState == HIGH) {
    // If the button is pressed, do something
    // ...
  } else {
    // If the button is not pressed, do something else
    // ...
  }
}

Note: The above code assumes that the KY-004 module is connected with a pull-up resistor. If you're using the internal pull-up resistor of the Arduino, you can initialize the button pin with pinMode(buttonPin, INPUT_PULLUP);.

Troubleshooting and FAQs

Common Issues Users Might Face

  • Button not responding: Ensure that all connections are secure and the power supply is within the operating voltage range.
  • Unstable button readings: Implement software debouncing or check the pull-up/pull-down resistor.

Solutions and Tips for Troubleshooting

  • Check Connections: Double-check wiring against the pin configuration table.
  • Debounce the Button: Use software debouncing techniques to filter out spurious signals.
  • Test with a Multimeter: Use a multimeter to ensure the button is functioning correctly when pressed.

FAQs

  • Q: Can I use the KY-004 module with a 3.3V system?

    • A: Yes, the KY-004 can operate within a 3.3V to 5V range.
  • Q: How do I know if the button is pressed in my code?

    • A: The digitalRead function will return HIGH if the button is pressed, assuming a pull-up resistor is used.
  • Q: What is the purpose of the pull-up resistor?

    • A: The pull-up resistor ensures that the input pin is at a known voltage when the switch is open (not pressed).

This documentation provides a comprehensive guide to using the KY-004 Key Switch Module in your projects. For further assistance, consult the community forums or technical support of your microcontroller platform.