I have been trying to find a digitalWrite code that only sends the sign to my Output once and if the requirement met again, It will not sends the signal again to my output.
Basically my project consists of Relay, LDR, RTC and Sound Sensor.
When RTC== true && LDR >Value (Relay remain On)
When RTC== true && LDR <Value (Relay Off once and my Sound Sensor can On and Off the Relay)
When RTC==false (Sound sensor can On & Off Relay)
I manage to Solve When RTC== true && LDR <Value (Relay remain On) & When RTC==false (Sound sensor can On & Off Relay)
Now I need a digitalWrite code that only sends a signal to my relay to Off it When RTC==true && LDR <Value only one-time so I can On my relay without it Off my relay again...
joshuatoh:
I have been trying to find a digitalWrite code that only sends the sign to my Output once and if the requirement met again, It will not sends the signal again to my output.
The usual way to do that is to have a variable that gets changed when the first output occurs. Something like
if (outputDoneOnce == false) {
outputDoneOnce = true;
digitalWrite(outputPin, HIGH); // or LOW
}
However if your digitalWrite() is just setting a pin HIGH (or LOW) repeating that won't matter and won't have any affect on the state of the pin.
If you need more help please post the program that represents your best attempt and tell us in detail what it actually does and what you want it to do that is different.