دائرة حساس اهتزاز باستخدام اردوينو نانو
Vibration Sensor Circuit Using Arduino Nano
int led = 3;
int vs = 12; // vibration sensor
void setup() {
pinMode(led, OUTPUT);
pinMode(vs, INPUT);
Serial.begin(9600);
}
void loop() {
long measurement = vibration();
delay(50);
Serial.println(measurement);
if (measurement > 7000) {
digitalWrite(led, HIGH);
delay(2000);
}
else {
digitalWrite(led, LOW);
}
}
long vibration() {
long measurement = pulseIn (vs, HIGH); //wait for the pin to get HIGH and returns measurement
return measurement;
}