Instructions
IDUINO for maker’s life
64 www.openplatform.cc
3.Example
This example show you how to use this module, connection as below, and upload the
sketch, open the serial monitor session, see how it will go~
Example code :
******Code begin******
int shockPin = 10; // Use Pin 10 as our Input
int shockVal = HIGH; // This is where we record our shock measurement
boolean bAlarm = false;
unsigned long lastShockTime; // Record the time that we measured a shock
int shockAlarmTime = 250; // Number of milli seconds to keep the shock
alarm high
void setup ()
{
Serial.begin(9600);
pinMode (shockPin, INPUT) ; // input from the KY-002
}
void loop ()
{
shockVal = digitalRead (shockPin) ; // read the value from our sensor
if (shockVal == LOW) // If we're in an alarm state
{