arduino sw-18010p vibration sensor connections

Thread Starter

enesene

Joined Mar 3, 2020
29
SW-18010P-Vibration-Sensor-Module-Vibration-Switch-Alarm-Module-Diy-Kit.jpg

i have a vibration sensor like that but it has 4 pins. Normally i have water level sensor module, too but it only has 3 pins (input, Vin and gnd). Water sensor makes LED on when it has water on it. then i replaced this vibration sensor to arduino same the way i connect water sensor but it doesn't work. could you please help me how can i make led logic 1 when sensor is vibrated.

the code i used:

C:
const int waterSens = A0;
const int led = 9;
int sensorVal;
void setup() {
Serial.begin(9600);
pinMode(led, OUTPUT);
}
void loop() {
  int sensorVal = analogRead(waterSens);
  if(sensorVal > 200){
    digitalWrite(led, HIGH);
  }
else{
   digitalWrite(led, LOW);
}
Serial.println(sensorVal);
}
Moderators note : Please use code tags for pieces of code
 
Last edited by a moderator:
Top