Stufin
Home Quick Cart Profile

4-Pins DIP Momentary Square Tactile Push Button Switch 10 Pieces - 6x6x8mm

Buy Now on Stufin

Operating Voltage

12V DC (maximum)

Contact Resistance

50 m

Insulation Resistance

100 M

Operating Life

100,000 cycles

Environmental Characteristics

Operating Temperature

-20C to 70C

Storage Temperature

-40C to 85C

Humidity

90% RH (non-condensing)

Applications

The 4-Pins DIP Momentary Square Tactile Push Button Switch is suitable for a wide range of applications, including

Electronic devices with limited space, such as wearable devices, smart home devices, and IoT projects.

Industrial control systems, robotics, and automation.

Medical devices, audio equipment, and other applications requiring tactile feedback and momentary action.

Packaging and Availability

The switch comes in a package of 10 pieces, making it an ideal option for prototyping, development, and production runs.

Pin Configuration

  • Component Documentation: 4-Pins DIP Momentary Square Tactile Push Button Switch
  • Overview
  • The 4-Pins DIP Momentary Square Tactile Push Button Switch is a compact, through-hole mounted switch designed for use in a variety of IoT applications. It features a durable and tactile feedback mechanism, making it suitable for use in devices that require user input.
  • Pinout Description
  • The switch has a 4-pin Dual In-Line Package (DIP) configuration, with each pin serving a specific purpose. Below is a detailed description of each pin:
  • Pin 1: NC (Normally Closed)
  • Function: Provides a connection to the common terminal when the switch is in its normal, unpressed state.
  • State: Normally connected to the COM pin when the switch is not pressed.
  • Electrical Characteristics:
  • + Voltage Rating: Depends on the specific application, but typically up to 12V DC or 6V AC.
  • + Current Rating: Typically up to 50mA.
  • Pin 2: COM (Common)
  • Function: The common terminal that connects to either the NC or NO pin, depending on the switch's state.
  • State: Connects to NC when the switch is not pressed, and NO when the switch is pressed.
  • Electrical Characteristics:
  • + Voltage Rating: Depends on the specific application, but typically up to 12V DC or 6V AC.
  • + Current Rating: Typically up to 50mA.
  • Pin 3: NO (Normally Open)
  • Function: Provides a connection to the common terminal when the switch is pressed.
  • State: Normally open, connecting to the COM pin only when the switch is pressed.
  • Electrical Characteristics:
  • + Voltage Rating: Depends on the specific application, but typically up to 12V DC or 6V AC.
  • + Current Rating: Typically up to 50mA.
  • Pin 4: None (Unused)
  • Function: No connection is made to this pin. It is typically left unconnected or can be used as a mounting point for the switch.
  • Connection Structure
  • When connecting the 4-Pins DIP Momentary Square Tactile Push Button Switch, follow this basic structure:
  • Connect one side of your circuit (e.g., a power source or a microcontroller pin) to the COM pin (Pin 2).
  • Connect the other side of your circuit to either the NC pin (Pin 1) or the NO pin (Pin 3), depending on the desired switch behavior:
  • + For a normally closed connection, connect to the NC pin.
  • + For a normally open connection, connect to the NO pin.
  • Leave Pin 4 unconnected or use it as a mounting point.
  • Example Connection Diagram
  • Here is a simple example of a push-button switch connected to a microcontroller and an LED:
  • ```
  • +---------------+
  • | Micro |
  • | Controller |
  • +---------------+
  • |
  • | Digital Pin
  • v
  • +---------------+
  • | COM (Pin 2) |
  • | Switch |
  • +---------------+
  • |
  • | NO (Pin 3)
  • v
  • +---------------+
  • | LED |
  • | (Anode) |
  • +---------------+
  • |
  • | GND
  • v
  • +---------------+
  • | Power |
  • | Source |
  • +---------------+
  • ```
  • In this example, when the switch is pressed, the NO pin connects to the COM pin, completing the circuit and illuminating the LED. When the switch is released, the circuit is broken, and the LED turns off.
  • Important Notes
  • Ensure the switch is properly mounted and secured to prevent mechanical stress and damage.
  • When choosing a power source and components, consider the voltage and current ratings of the switch to avoid damage or electrical overstress.
  • Refer to the datasheet for specific values and tolerances for the switch's electrical characteristics.

Code Examples

Component Documentation: 4-Pins DIP Momentary Square Tactile Push Button Switch 10 Pieces - 6x6x8mm
Overview
The 4-Pins DIP Momentary Square Tactile Push Button Switch is a compact, durable, and versatile switch designed for a wide range of IoT applications. With its small form factor (6x6x8mm) and DIP (Dual In-Line Package) design, it is easy to integrate into breadboards, PCBs, or other electronic circuits.
Pinout
The switch has four pins, labeled as follows:
Pin 1: NC (Normally Closed)
 Pin 2: COM (Common)
 Pin 3: NO (Normally Open)
 Pin 4: GND (Ground)
Operating Principle
The switch operates as a momentary switch, meaning it only closes the connection between the NO (Normally Open) and COM (Common) pins when pressed. When released, the connection opens, and the switch returns to its normal state.
Code Examples
### Example 1: Basic Switch Debouncing with Arduino
In this example, we'll use the switch to trigger an LED to turn on and off. We'll also implement debouncing to prevent multiple switch registrations when the button is pressed.
```c++
const int switchPin = 2;  // Pin connected to NO (Normally Open) of the switch
const int ledPin = 13;   // Pin connected to an LED
bool switchState = false;
bool lastSwitchState = false;
void setup() {
  pinMode(switchPin, INPUT);
  pinMode(ledPin, OUTPUT);
}
void loop() {
  bool currentState = digitalRead(switchPin);
  if (currentState != lastSwitchState) {
    delay(50); // Debouncing delay
    if (currentState == HIGH) {
      switchState = !switchState;
    }
  }
  lastSwitchState = currentState;
if (switchState) {
    digitalWrite(ledPin, HIGH);
  } else {
    digitalWrite(ledPin, LOW);
  }
}
```
### Example 2: Raspberry Pi GPIO Interrupt with Python
In this example, we'll use the switch to trigger a Python script when pressed. We'll use the RPi.GPIO library to set up an interrupt on the GPIO pin connected to the switch.
```python
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
switch_pin = 17  # Pin connected to NO (Normally Open) of the switch
GPIO.setup(switch_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
def switch_callback(channel):
    print("Switch pressed!")
    # Add your custom code here, e.g., sending a notification or controlling an LED
GPIO.add_event_detect(switch_pin, GPIO.FALLING, callback=switch_callback, bouncetime=200)
try:
    while True:
        time.sleep(1)
except KeyboardInterrupt:
    GPIO.cleanup()
```
### Example 3: ESP32 Microcontroller with C++
In this example, we'll use the switch to trigger a simple Wi-Fi network scan when pressed.
```c++
#include <WiFi.h>
const int switchPin = 5;  // Pin connected to NO (Normally Open) of the switch
void setup() {
  Serial.begin(115200);
  pinMode(switchPin, INPUT);
}
void loop() {
  int switchState = digitalRead(switchPin);
  if (switchState == HIGH) {
    Serial.println("Switch pressed!");
    // Perform Wi-Fi network scan
    WiFi.scanNetworks();
    delay(1000);
  }
}
```
Additional Notes
When using the switch with microcontrollers or single-board computers, ensure that the GPIO pin connected to the switch is configured correctly as an input.
 In some cases, you may need to add a pull-up or pull-down resistor to the switch pin to ensure proper operation.
 The above code examples assume that the switch is connected to a digital input pin. If you're using an analog input pin, you'll need to modify the code accordingly.