
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);
}
Last edited by a moderator: