

A button switch, manufactured by Keyestudio (Part ID: Switch Module), is a mechanical device that allows users to open or close an electrical circuit by pressing a button. This simple yet versatile component is widely used in various applications, such as turning devices on or off, triggering events in microcontroller projects, or acting as an input device in user interfaces.








The Keyestudio button switch module is designed for ease of use in prototyping and educational projects. Below are its key technical details:
The button switch module has a simple 3-pin configuration:
| Pin | Label | Description |
|---|---|---|
| 1 | GND | Ground connection |
| 2 | VCC | Power supply (3.3V or 5V) |
| 3 | SIG | Signal output (HIGH when pressed, LOW otherwise) |
The Keyestudio button switch module is straightforward to use in electronic circuits. Below are the steps and best practices for integrating it into your project.
Connect the Pins:
Read the Signal:
Debouncing:
Below is an example of how to use the button switch module with an Arduino UNO to turn an LED on and off:
// Define pin connections
const int buttonPin = 2; // SIG pin of the button switch connected to digital pin 2
const int ledPin = 13; // Built-in LED on Arduino UNO
// Variable to store button state
int buttonState = 0;
void setup() {
pinMode(buttonPin, INPUT); // Set button pin as input
pinMode(ledPin, OUTPUT); // Set LED pin as output
}
void loop() {
// Read the state of the button
buttonState = digitalRead(buttonPin);
// If the button is pressed, turn on the LED
if (buttonState == HIGH) {
digitalWrite(ledPin, HIGH); // Turn on LED
} else {
digitalWrite(ledPin, LOW); // Turn off LED
}
}
Button Press Not Detected:
Unstable Signal (Bouncing):
No Signal Output:
Signal Always HIGH or LOW:
Q1: Can I use the button switch module with a 3.3V microcontroller?
A1: Yes, the module is compatible with both 3.3V and 5V systems.
Q2: Do I need an external pull-up resistor?
A2: The module may already include a pull-up resistor. If not, you can enable the internal pull-up resistor on your microcontroller or add an external one.
Q3: How do I debounce the button in software?
A3: You can use a delay or a state-checking algorithm in your code to filter out bouncing signals.
Q4: Can I use this module for long-term applications?
A4: Yes, but ensure the button is not exposed to excessive mechanical stress or environmental factors like moisture.
By following this documentation, you can effectively integrate the Keyestudio button switch module into your projects and troubleshoot any issues that arise.