The Red Momentary Switch with a 32 mm diameter is a push-to-make (normally open) switch that closes the circuit only while the button is being pressed and breaks the circuit once the button is released. This type of switch is ideal for applications requiring a temporary action, such as starting a machine, triggering a bell, or input for electronic projects.
Pin Number | Description |
---|---|
1 | Normally Open (NO) |
2 | Common (COM) |
// Define the pin connected to the switch
const int switchPin = 2;
void setup() {
pinMode(switchPin, INPUT_PULLUP); // Set the switch pin as input with internal pull-up
Serial.begin(9600); // Start serial communication at 9600 baud
}
void loop() {
// Check if the switch is pressed
if (digitalRead(switchPin) == LOW) {
// The switch is pressed (circuit closed)
Serial.println("Switch Pressed");
// Add code here to perform an action when the switch is pressed
} else {
// The switch is not pressed (circuit open)
Serial.println("Switch Released");
// Add code here to perform an action when the switch is released
}
delay(100); // Debounce delay to avoid flickering
}
Q: Can this switch be used with a DC circuit? A: Yes, the switch can be used with both AC and DC circuits, as long as the voltage and current do not exceed the switch's ratings.
Q: Is debouncing necessary for this switch? A: Yes, debouncing is recommended to ensure stable switch readings, especially in digital applications.
Q: How do I mount this switch? A: The switch typically comes with a threaded body and a nut for mounting through a panel. Ensure the hole in the panel matches the diameter of the switch for a proper fit.