Hi, Am trying to build a unit that cuts the power when there is salt water connecting the two wires. Have GND and 7 that works fine and turn on off the built in led. Then I connect the relay to 5v, GND and dig 8. The relay then starts vibrating, I am guessing on/off cycles which I couldnt see the led doing. Added a delay, which "cools" things down... But same result....
I sincerly hope now that I didnt post this the wrong way, have even tried to format the code better....
const int floodSensors = 7;
const int ledPin = 13;
#define RELAY_PIN 8
// variables will change:
int floodSensorState = 0;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(floodSensors, INPUT);
pinMode(RELAY_PIN, OUTPUT);
}
void loop(){
floodSensorState = digitalRead(floodSensors);
if (floodSensorState == HIGH) {
digitalWrite(ledPin, HIGH);
digitalWrite(RELAY_PIN, HIGH);
}
else {
digitalWrite(ledPin, LOW);
digitalWrite(RELAY_PIN, LOW);
}
}
![20240107_182419|666x500](upload://3jMa9uiKcVsuyDO3rp2fQ8kTJwv.jpeg)