Difference between revisions of "Collision Switch Module"

From Wiki
Jump to: navigation, search
(Experimental Procedures For Arduino)
(Experimental Procedures For Arduino)
 
Line 85: Line 85:
  
 
</pre>
 
</pre>
当模块检测到碰撞以后,串行端口会输出 “Switch Pressed!”与此同时,uno板上的13pin led也会亮起
+
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.

Latest revision as of 09:45, 3 September 2019

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.