The Blue Button Tact Switch is a momentary push-button switch that is activated when pressed. It is widely used in various electronic devices for user input, allowing users to interact with the device easily. Common applications include remote controls, keyboards, and various consumer electronics. Its compact size and reliable performance make it a popular choice for hobbyists and professionals alike.
Specification | Value |
---|---|
Operating Voltage | 12V DC |
Current Rating | 50mA |
Power Rating | 0.6W |
Contact Resistance | < 100 Ohms |
Actuation Force | 160 - 300g |
Lifespan | 100,000 cycles |
Pin Number | Pin Name | Description |
---|---|---|
1 | NO | Normally Open - connects when pressed |
2 | COM | Common - connects to ground or power |
3 | NC | Normally Closed - connects when not pressed (optional) |
Switch Not Responding:
Multiple Signals on a Single Press:
Switch Sticking:
const int buttonPin = 2; // Pin connected to the switch
int buttonState; // Current state of the button
int lastButtonState = LOW; // Previous state of the button
unsigned long lastDebounceTime = 0; // Last time the button state changed
unsigned long debounceDelay = 50; // Debounce time in milliseconds
void setup() {
pinMode(buttonPin, INPUT);
Serial.begin(9600);
}
void loop() {
int reading = digitalRead(buttonPin);
// Check if the button state has changed
if (reading != lastButtonState) {
lastDebounceTime = millis(); // Reset the debounce timer
}
// If the button state has been stable for the debounce delay
if ((millis() - lastDebounceTime) > debounceDelay) {
// If the button state has changed
if (reading != buttonState) {
buttonState = reading; // Update the button state
// Print the button state to the Serial Monitor
Serial.println(buttonState == HIGH ? "Button Pressed" : "Button Released");
}
}
lastButtonState = reading; // Save the reading for the next loop
}
This code reads the state of the button and prints whether it is pressed or released, while handling debouncing to ensure accurate readings.
By following this documentation, users can effectively utilize the Blue Button Tact Switch in their electronic projects, ensuring reliable performance and user interaction.