Introduction
A miniature snap-action switch, also trademarked and frequently known as a micro switch, is an electric switch that is actuated by very little physical force. Micro switches are very widely used; among their applications are appliances, machinery, industrial controls, vehicles, and many other places for control of electrical circuits. They are usually rated to carry current in control circuits only, although some switches can be directly used to control small motors, solenoids, lamps, or other devices.
This is a small micro switch sensor designed for the Arduino micro controller. It could be directly connected to the IO Expansion shield. It integrates the pull-up resistor and the status indicator LED onboard. This makes it easier for testing and integration. The miniature snap-action micro switch with roller lever makes it suitable for more different environment application and can be applied to any imaginative project you can think of!
Common Applications
- Levelling and safety switches in elevators
- Door interlock on a microwave oven
- Vending machines
- Detect paper jams or other faults in photocopiers
- 3D Printer position feedback,etc...
Specification
- Working Voltage: 5v
- Pinout:
- 1 Digital output
- 2 VCC
- 3 GND
- Onboard status indicator LED
- Directly connected to the IO Expansion shield For Arduino
- M3 mounting hole x2
- Size: 30x20x8mm
Documents
Connection Diagram
Sample Code
// #
// # Editor : Lauren from DFRobot
// # Date : 26.09.2012
// # E-Mail : Lauren.pan@dfrobot.com
// # Product name: Crash sensor
// # Product SKU : SEN0138
// # Version : 0.1
int ledPin = 13; // choose the pin for the LED
int inputPin = 3; // Connect sensor to input pin 3
void setup() {
Serial.begin(9600); // Init the serial port
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inputPin, INPUT); // declare Micro switch as input
}
void loop(){
int val = digitalRead(inputPin); // read input value
if (val == HIGH) { // check if the input is HIGH
digitalWrite(ledPin, LOW); // turn LED OFF
} else {
digitalWrite(ledPin, HIGH); // turn LED ON
Serial.println("Switch Pressed!");
}
delay(50);
}