The 3104 push button is a momentary switch that is widely used in electronic circuits. When the button is pressed, it closes the circuit, allowing electric current to flow through. Upon release, the button returns to its default position, opening the circuit and stopping the current. This simple yet versatile component is commonly found in applications such as input devices, control panels, and hobbyist projects, including interfacing with microcontrollers like the Arduino UNO.
Pin Number | Description |
---|---|
1 | Terminal 1 (Contact) |
2 | Terminal 2 (Contact) |
Note: The pins are usually interchangeable since the push button acts as a simple switch.
To use the 3104 push button in a circuit:
Below is an example of how to use the 3104 push button with an Arduino UNO:
// Define the pin connected to the push button
const int buttonPin = 2;
// Define the pin for the LED
const int ledPin = 13;
// Variable for reading the push button status
int buttonState = 0;
void setup() {
// Initialize the LED pin as an output
pinMode(ledPin, OUTPUT);
// Initialize the push button pin as an input
pinMode(buttonPin, INPUT_PULLUP);
}
void loop(){
// Read the state of the push button value
buttonState = digitalRead(buttonPin);
// Check if the push button is pressed
// if it is, the buttonState is LOW
if (buttonState == LOW) {
// Turn on the LED
digitalWrite(ledPin, HIGH);
} else {
// Turn off the LED
digitalWrite(ledPin, LOW);
}
}
Note: The INPUT_PULLUP
mode enables the internal pull-up resistor, which is a best practice for push button circuits.
Q: Can I use the 3104 push button with AC voltage? A: No, the 3104 push button is rated for DC voltage only.
Q: How can I prevent "bouncing" when the button is pressed? A: Implement a debounce algorithm in your code or use a capacitor and resistor to create a hardware debounce circuit.
Q: Is it necessary to use a resistor with the push button? A: Yes, using a pull-up or pull-down resistor is recommended to ensure a defined logic level when the button is not pressed.
For further assistance, please refer to the manufacturer's datasheet or contact technical support.