Description
- The KY-004 Push Button Switch Module is a small and simple electronic component designed to provide an easy way to add push button functionality to a microcontroller project. It consists of a small micro switch with two contacts, which can be activated by pressing the button. The module also includes a built-in pull-up resistor, which means that it can be connected directly to a microcontroller input pin without the need for additional components.
- The module is compatible with any microcontroller system, making it a versatile and convenient choice for a wide range of projects. It can be used as a simple on/off button, or as part of more complex input systems such as menus or user interfaces.
- The KY-004 Push Button Switch Module is easy to use and requires minimal setup. Simply connect the module to the microcontroller using the included pins, and then use the appropriate code to detect button presses and trigger actions in your project.
Specification:
- Material: FR4
- Operating Voltage: 5V DC
- Type: Push Button Key Switch
- Max Operating Force: 180 / 230 ( ±20gf)
- Durability: 100,000 cycles
- Dimension: 25 x 16 x 10mm
- Weight: 1.5g
Applications:
- User interfaces: The module can be used as part of a user interface or control panel for a microcontroller project, allowing users to trigger specific actions or commands by pressing a button.
- Sensor inputs: The module can be used as a simple sensor input, triggering an event or action in response to a physical input from a user or other source.
- Alarm systems: The module can be used as a trigger for an alarm or alert system, such as a panic button or emergency stop.
- Robotics: The module can be used in robotics projects as a simple input device, allowing users to control or interact with robots or other automated systems.
- Home automation: The module can be used as part of a home automation system, triggering actions such as turning on lights or opening doors when a button is pressed.
Pin Connections:
Pin | Description | Connection |
---|---|---|
"-" | Ground | Connect to Ground |
"+5V" | Positive Power | Connect to Positive Power Supply |
"S" | Digital Signal to Microcontroller | Connect to Digital Input on MCU |
Package Includes:
- 1 x Push Button Switch Module KY-004
Sample Project:
Circuit:
- Connection details
- LED + = [Pin 13]
- LED - = [Pin GND]
- Sensor Signal = [Pin 10]
- Sensor +V = [Pin 5V]
- Sensor - = [Pin GND]
Library:
- No external library is requrired for this module to work.
Code
int Led = 13 ;// Declaration of the LED-output pin
int Sensor = 10; // Declaration of the sensor input pin
int val; // Temporary variable
void setup ()
{
pinMode (Led, OUTPUT) ; // Initialization output pin
pinMode (Sensor, INPUT) ; // Initialization sensor pin
digitalWrite(Sensor, HIGH); // Activating of the internal pull-up resistor
}
void loop ()
{
val = digitalRead (Sensor) ; // The current signal from the sensor will be read
if (val == HIGH) // If a signal will be detected, the LED will light up.
{
digitalWrite (Led, LOW);
}
else
{
digitalWrite (Led, HIGH);
}
}