Introduction
The proximity switch usually possesses the characteristics of travel switch, micro switch and sensor. This is a small 5V metal proximity switch with 27106mm size, which can be easily mounted in tight space. It features NPN (normally open) output, 4mm detection distance, 1000Hz switching frequency. The response time is less than 1ms, quick and stable. These sensors are IP67 rated, which can withstand a temperature range of -20℃~65℃. So, this sensor can be used indoor and outdoor regardless of the weather.
This proximity switch should be operated at 5V. It can be used not only in machinery automation, security equipment, car anti-theft and other operations, but also in the hands of makers with various controller boards for robot runway conversion, speed detection, etc.
Specification
- Voltage: 5V
- Current: 30mA
- Detection Distance: 4mm
- Output: NPN (normally open)
- Detection Target: metal
- Wire Length: about 2m
- Sensing Type: inductive
- Protection: IP67
- Operating Temperature: -20℃~65℃
- Switching Frequency: 1000Hz
- Response Time: <1ms
- Dimension: 27106mm/1.060.390.24”
Pinout
Color | Function Description |
---|---|
Black | Signal Line |
Brown | Power Input(5V) |
Blue | GND |
Tutorial
Requirements
- Hardware
- DFRduino UNO R3 (or similar) x 1
- 5V Metal Proximity Switch x1
- Software
Connection Diagram
Sample Code
const int SensorPin = 4;
const int LedPin = 13;
void setup()
{
Serial.begin(9600);
Serial.println("Start!");
pinMode(SensorPin,INPUT);
pinMode(LedPin,OUTPUT);
digitalWrite(LedPin,LOW);
}
void loop()
{
if(digitalRead(SensorPin) == LOW)
digitalWrite(LedPin,LOW);
else
digitalWrite(LedPin,HIGH);
Serial.print("Infrared Switch Status:");
Serial.println(digitalRead(SensorPin),BIN);
delay(50);
}
Expected Results
In the Arduino serial port monitor, you can see the change of the switch state when the sensor detects the metal object, when the metal object is not detected, the status is 1, and it is 0 when detected; you can also observe whether the metal object is detected by the state of indicator on UNO board or the light on the sensor, and the indicator light is on when the metal object is detected, otherwise, off.
Note:
The effective detection distance is in 4mm, and the diameter of the detected object should be greater than or equal to 1mm.
The object shall be placed in the detection area, otherwise, it may not work.
FAQ
For any questions, advice or cool ideas to share, please visit the DFRobot Forum