Help, I want to use arduino to control relay for electricity, i get data from a sensor and when a value is detected it should be constantly on until another detection triggered again, i can get the program to work but triggered only once instead when it should be constantly turned on, here'e my code:
int Pinout = 13;
void setup() {
Serial.begin(9600);
pinMode(Pinout, OUTPUT);
}
void loop() {
int val = analogRead(A0);
if (val <= 500) {
digitalWrite(Pinout, LOW);
}
else {
digitalWrite(Pinout, HIGH);
}
}
the relay i am using is a chinese relay module with 3 pin and VCC and GND connected to external power supply, and INput pin to 13 digital pin Arduino and the relay is which i believed is Active LOW, and for analog read i am using moisture sensor