Collision Switch Module

From Wiki
Revision as of 09:45, 3 September 2019 by Root (Talk | contribs) (Experimental Procedures For Arduino)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Introduction

The Crash sensor is a miniature snap-action switch. It is also known as micro switch, an electric switch activated by a small physical force.
Collision Switch Module(front).pngCollision Switch Module(rear).png

feature

  • Special module with ports compatible with the expansion board of sensor.
  • Output low level when the module is activated; keep outputting high level at the state of release.
  • Applied in the detection of collision and touching impact.

Introduction of Pins

Introduction of Pins
     OUT
     Switching signal output
     VCC
     positive pole
     GND
     negative pole

principle

Getting an impact, the switch outputs low level, or else it outputs high level.
Collision Switch Module schematic diagram.png

Experimental Procedures For Arduino

Step 1: Connect the circuit:

Creshsensor Uno Board
VCC 5V
GND GND
D0 2

Collision Switch Module(Fritzing).png
Step 2: Compile and upload the code Using SunFounder Uno

int ledPin = 13;                // choose the pin for the LED
int inputPin = 2;               // 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 == LOW) {                // check if the input is HIGH
digitalWrite(ledPin, HIGH);      // turn LED ON
Serial.println("Switch Pressed!");
  } else {
    digitalWrite(ledPin, LOW);     // turn LED OFF 
  }
  delay(50);
}

When the module detects the impact, the serial port will output “Switch Pressed!”Meanwhile, the LED on the pin 13 of the UNO board will light up.