Hit Sensor Module
Hit Sensor Module
DESCRIPTION:
This module also called knock switch, if you hit this module, the signal pin would pinout High
level signal.
Specification:
● Operation voltage: 5V
● 3Pin
● Size:24.5*15.5mm
● Weight: 1.604g
PIN CONFIGURATION:
1、“S”: Digital signal input pin, if it detect a knock,it output High level
2、 “+” : +5V
3、 “-”: Ground
Example:
This example shows you how to use this module to catch a hit, which is different to
the shock. If you hit this module, the LED13 will light on.
The connection as below:
1/2
Code:
int Led=13;
int Shock=3;
int val;
void setup()
{
pinMode(Led,OUTPUT);
pinMode(Shock,INPUT);
}
void loop()
{
val=digitalRead(Shock);
if(val==HIGH)
{
digitalWrite(Led,LOW);
}
else
{
digitalWrite(Led,HIGH);
}
}
2/2