The Keyestudio Button Sensor Module is a simple yet versatile device designed to detect the presence or absence of a button press. It features a push button switch and additional circuitry to provide a clean digital output signal when the button is activated. This module is widely used in projects requiring user input, such as triggering events, controlling devices, or navigating menus in embedded systems.
The Keyestudio Button Sensor Module is designed for ease of use and compatibility with a wide range of microcontrollers, including Arduino boards.
The module has a 3-pin interface for easy connection to microcontrollers. Below is the pinout:
Pin | Label | Description |
---|---|---|
1 | GND | Ground connection |
2 | VCC | Power supply (3.3V to 5V) |
3 | SIG | Digital signal output (HIGH/LOW) |
The Keyestudio Button Sensor Module is straightforward to use in any circuit. Follow the steps below to integrate it into your project:
VCC
pin to the 3.3V or 5V pin of your microcontroller and the GND
pin to the ground.SIG
pin to a digital input pin on your microcontroller.VCC
pin to the Arduino UNO's 5V
pin.GND
pin to the Arduino UNO's GND
pin.SIG
pin to digital pin 2
on the Arduino UNO.Below is an example Arduino sketch to read the button state and control the onboard LED:
// Define the pin connected to the button sensor module
const int buttonPin = 2; // SIG pin connected to digital pin 2
const int ledPin = 13; // Onboard LED pin on Arduino UNO
void setup() {
pinMode(buttonPin, INPUT); // Set button pin as input
pinMode(ledPin, OUTPUT); // Set LED pin as output
Serial.begin(9600); // Initialize serial communication
}
void loop() {
int buttonState = digitalRead(buttonPin); // Read the button state
if (buttonState == HIGH) {
// If button is pressed, turn on the LED
digitalWrite(ledPin, HIGH);
Serial.println("Button Pressed");
} else {
// If button is not pressed, turn off the LED
digitalWrite(ledPin, LOW);
Serial.println("Button Released");
}
delay(100); // Small delay to debounce the button
}
delay(100)
) or implement software debouncing for reliable readings.No Response from the Button:
VCC
and GND
connections).SIG
pin is connected to the correct digital input pin on the microcontroller.Button Press Not Detected Consistently:
Onboard LED Does Not Light Up:
Q: Can I use this module with a Raspberry Pi?
A: Yes, the module is compatible with Raspberry Pi. Connect the SIG
pin to a GPIO pin configured as an input, and ensure the operating voltage is 3.3V to avoid damaging the Raspberry Pi.
Q: Does the module work with 3.3V microcontrollers?
A: Yes, the module operates at both 3.3V and 5V, making it compatible with a wide range of microcontrollers.
Q: How do I extend the button's functionality?
A: You can use the button to trigger interrupts, control relays, or navigate menus in your project. Modify the code to suit your specific application.
By following this documentation, you can effectively integrate the Keyestudio Button Sensor Module into your projects and troubleshoot any issues that arise.