How to use the Impact Switch Sensor with Arduino

How to use the Impact Switch Sensor with Arduino

Impact Switch Sensor

INTRODUCTION

An Impact Switch sensor detects the collision with an object. When the switch is in the pressed down position, it sends a signal to the system that a moving object has reached its maximum allowable position or moving distance. This sensor is also widely known as a limit sensor/switch.

APPLICATIONS

This sensor is used in various industrial manufacturing, commercial warehousing and logistics operations. For example, the impact switch can be used to detect if a garage door is open or closed. The light in your refrigerator turns on automatically by the use of a limit sensor.

WIRING DIAGRAM

VCC – 5V

OUT – Digital Pin 7

GND - GND

Impact Switch with Arduino pin connections

CODE 

int sensorPin=7;
boolean val =0;

void setup(){
  
  pinMode(sensorPin, INPUT);
  Serial.begin (9600);
}
  
void loop (){
  val =digitalRead(sensorPin);
  
  // the sensor detects a signal when pressed and prints to the serial monitor
  if (val==LOW) {
    Serial.println("pressed");
  }
  else {
    Serial.println("unpressed");
  }
}

END RESULT

Open serial monitor where you can observe the colliding/pressing activity of the sensor. Note the sensor input is LOW when it is pressed.

ADDITIONAL RESOURCES

https://wiki.dfrobot.com/Crash_Sensor__SKU__SEN0138_