• Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
HomeArduinoSensors Kit for ArduinoKY002: Shock Sensor Module
Previous Next

KY002: Shock Sensor Module

Posted by: admin , April 24, 2014

[vc_row][vc_column width=”1/1″][vc_column_text]KY002

 

Use the LED that is connected to digital 13, and connect the vibration sensor output to digital pin 3. When the vibration sensor detects vibration, the LED will blink.

Sample Code:

int Led=13;//define LED interface

int Shock=3//define vibration sensor interface

int val;//define digital varible val

void setup()

{

pinMode(Led,OUTPUT);//define LED as output 

pinMode(Shock,INPUT);//define shock as input

}

void loop()

{

val=digitalRead(Shock);//

if(val==HIGH)//

{

digitalWrite(Led,LOW);

}

else

{

digitalWrite(Led,HIGH);

}

}

[/vc_column_text][/vc_column][/vc_row]

Tags: Sensors Kit for Arduino

Share!
Tweet

admin

About the author

Leave a Reply Cancel reply

You must be logged in to post a comment.

Category

  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors