[vc_row][vc_column width=”1/1″][vc_column_text]
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]
Leave a Reply
You must be logged in to post a comment.