

A momentary switch is a type of switch that only remains in the 'on' position while being pressed. It automatically returns to its 'off' position when released. This behavior makes it ideal for applications where a temporary connection is required. Common use cases include doorbells, keyboard keys, reset buttons, and other control interfaces where a brief activation is sufficient.








Momentary switches typically have two or more pins. Below is a general description of the pin configuration:
| Pin Name | Description |
|---|---|
| Pin 1 | One terminal of the switch. Connects to the circuit when the switch is pressed. |
| Pin 2 | The other terminal of the switch. Completes the circuit when the switch is pressed. |
For switches with additional pins (e.g., Normally Closed configurations):
| Pin Name | Description |
|---|---|
| Pin 3 | Common terminal (COM) for switches with multiple states (e.g., NO/NC). |
| Pin 4 | Normally Closed (NC) terminal. Disconnects when the switch is pressed. |
Below is an example of how to use a momentary switch to control an LED with an Arduino UNO:
// Define pin connections
const int switchPin = 2; // Momentary switch connected to digital pin 2
const int ledPin = 13; // LED connected to digital pin 13
void setup() {
pinMode(switchPin, INPUT_PULLUP); // Configure switch pin as input with pull-up resistor
pinMode(ledPin, OUTPUT); // Configure LED pin as output
}
void loop() {
int switchState = digitalRead(switchPin); // Read the state of the switch
if (switchState == LOW) { // Switch is pressed (LOW due to pull-up resistor)
digitalWrite(ledPin, HIGH); // Turn on the LED
} else {
digitalWrite(ledPin, LOW); // Turn off the LED
}
}
Notes:
INPUT_PULLUP mode enables the internal pull-up resistor, simplifying the circuit.LOW because it is connected to ground.Switch Not Working:
Switch Bouncing:
Switch Fails to Activate the Circuit:
Intermittent Operation:
Q: Can I use a momentary switch to control a motor?
Q: What is the difference between Normally Open (NO) and Normally Closed (NC) switches?
Q: How do I debounce a momentary switch in software?
By following this documentation, you can effectively integrate a momentary switch into your electronic projects!