Difference between revisions of "Collision Switch Module"

From Wiki
Jump to: navigation, search
(Introduction)
(Experimental Procedures For Arduino)
 
(37 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
=='''Introduction'''==
 
=='''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.
+
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.<br>
 
[[File:Collision Switch Module(front).png]][[File:Collision Switch Module(rear).png]] <br>
 
[[File:Collision Switch Module(front).png]][[File:Collision Switch Module(rear).png]] <br>
 +
 
=='''feature'''==
 
=='''feature'''==
 +
<ul>
 +
<li>Special module with ports compatible with the expansion board of sensor.</li>
 +
<li>Output low level when the module is activated; keep outputting high level at the state of release.</li>
 +
<li>Applied in the detection of collision and touching impact.</li>
 +
</ul>
 +
 +
=='''Introduction of Pins'''==
 +
<table border="5">
 +
<tr>
 +
<td colspan="2">Introduction of Pins</td>
 +
</tr>
 +
  <tr>
 +
    <td>
 +
      OUT
 +
    </td>
 +
    <td>
 +
      Switching signal output
 +
    </td>
 +
  </tr>
 +
  <tr>
 +
    <td>
 +
      VCC
 +
    </td>
 +
    <td>
 +
      positive pole
 +
    </td>
 +
  </tr>
 +
  <tr>
 +
    <td>
 +
      GND
 +
    </td>
 +
    <td>
 +
      negative pole
 +
    </td>
 +
  </tr>
 +
</table>
 +
=='''principle'''==
 +
Getting an impact, the switch outputs low level, or else it outputs high level.<br>
 +
[[ File:Collision Switch Module schematic diagram.png]]<br>
 +
=='''Experimental Procedures For Arduino '''==
 +
'''Step 1''': Connect the circuit:
 +
{| class="wikitable"
 +
|'''Creshsensor'''
 +
|'''Uno Board'''
 +
|-
 +
|VCC
 +
|5V
 +
|-
 +
|GND
 +
|GND
 +
|-
 +
|D0
 +
|2
 +
|}
 +
[[File:Collision Switch Module(Fritzing).png]]<br>
 +
'''Step 2''': Compile and upload the code
 +
Using SunFounder Uno
 +
<pre>
 +
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);
 +
}
 +
 +
</pre>
 +
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.