VIBRATION SENSOR SW 420

sw420

The code can be downloaded at:

https://github.com/triantara/ARDUINO-TRIANTARA/blob/main/SW-420%20vibration.zip

int led = 3;
// the setup routine runs once when you press reset:
void setup() {
pinMode(led, OUTPUT);
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// print out the value you read:
Serial.println(sensorValue);
delay(1); // delay in between reads for stability
if(sensorValue >10){
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(5000);
}
else{
Serial.println(sensorValue);
digitalWrite(led, LOW);
delay(1); // delay in between reads for stability
}
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s