I Need help in another project : i am using LDR and arduino uno and 2 relay module when LDR detects low light it trigger the relay my problem is when slight change in LDR value the relay gets flickering like fast on/ off how to get steady on or steady off ?? the relay module pin is connected to pin 12 on arduino uno... i am using the code below ..
--------------------------------------------------------------------------------------------------------------------------
void setup() {
pinMode(4, OUTPUT);
pinMode(12, OUTPUT);
//Serial.begin(9600);
}
void loop(){
digitalWrite(4, HIGH);
if(analogRead(0) < 600){
digitalWrite(12, LOW);
} else{
digitalWrite(12, HIGH);
//Serial.println(analogRead(0));
}
}
-----------------------------------------------------------------------------------------------------------------------