The Grove-LED Button is a versatile module that combines an LED and a push button into a single, compact unit. This module allows users to control the LED's state (on/off) with the press of a button, making it ideal for interactive projects. It is part of the Grove ecosystem, which simplifies prototyping and development by using standardized connectors and plug-and-play functionality.
The Grove-LED Button is designed for ease of use and compatibility with microcontrollers like Arduino, Raspberry Pi, and others. Below are its key technical details:
Parameter | Value |
---|---|
Operating Voltage | 3.3V / 5V |
Operating Current | ≤ 20mA |
LED Color | Red |
Button Type | Momentary Push Button |
Connector Type | Grove 4-pin Interface |
Dimensions | 20mm x 20mm |
Weight | 3g |
The Grove-LED Button uses a 4-pin Grove connector. The pinout is as follows:
Pin Number | Pin Name | Description |
---|---|---|
1 | VCC | Power supply (3.3V or 5V) |
2 | GND | Ground |
3 | SIG_LED | Signal pin to control the LED |
4 | SIG_BTN | Signal pin to read the button's state |
The Grove-LED Button is straightforward to use in a circuit. Follow the steps below to integrate it into your project:
Hardware Setup:
Circuit Diagram:
Below is an example Arduino sketch to demonstrate how to use the Grove-LED Button. The code toggles the LED state each time the button is pressed.
// Define the pin numbers for the LED and button
const int ledPin = 2; // Connect SIG_LED to digital pin 2
const int buttonPin = 3; // Connect SIG_BTN to digital pin 3
// Variable to store the button state
int buttonState = 0;
// Variable to track the LED state
bool ledState = false;
void setup() {
// Initialize the LED pin as an output
pinMode(ledPin, OUTPUT);
// Initialize the button pin as an input
pinMode(buttonPin, INPUT);
// Start the serial monitor for debugging
Serial.begin(9600);
}
void loop() {
// Read the current state of the button
buttonState = digitalRead(buttonPin);
// Check if the button is pressed
if (buttonState == HIGH) {
// Toggle the LED state
ledState = !ledState;
// Update the LED output
digitalWrite(ledPin, ledState ? HIGH : LOW);
// Print the LED state to the serial monitor
Serial.print("LED is now: ");
Serial.println(ledState ? "ON" : "OFF");
// Debounce delay to avoid multiple toggles
delay(200);
}
}
The LED does not light up:
The button press is not detected:
The LED flickers or behaves erratically:
The module does not work at all:
Q: Can I use the Grove-LED Button with a Raspberry Pi?
A: Yes, the module can be used with a Raspberry Pi. Use the GPIO pins to control the LED and read the button state. You may need a Grove Pi+ or Grove HAT for easier integration.
Q: Can I change the LED color?
A: The module comes with a fixed red LED. To use a different color, you would need to modify the hardware by replacing the LED.
Q: Is the button latching or momentary?
A: The button is momentary, meaning it only stays pressed while you hold it down.
Q: Can I use this module with 3.3V systems?
A: Yes, the Grove-LED Button is compatible with both 3.3V and 5V systems.
By following this documentation, you can easily integrate the Grove-LED Button into your projects and troubleshoot any issues that arise. Happy prototyping!