Forum Discussion
TNGW1500SE
Apr 12, 2018Explorer
2112 wrote:
Very nice, well executed job. I love spending my time creating gadgets nobody else would give a second thought about. It's what keeps us young and mentally active.
I apologize but I just can not let this go. I tried, honestly. I hate it when someone nit-picks my code so please forgive me for picking on yours.
You're writing D5 low a gazillion times for no reason. Does it work? Yes it does. Is it proper form? It is not. It's not event driven embedded code.
Move D5,LOW below the delay and remove the else. This way nothing happens until you press the button. When button is pressed water is turned on, delay 15 min's, water is turned off. Then it just sits there testing buttonState waiting for the button to be pressed again.
//*********************//
if (buttonState == HIGH) {
digitalWrite(D5,HIGH); // turn on
delay(900000); //15 min on time
digitalWrite(D5,LOW); // turn off
}
Please take this as constructive criticism.
I'm partial to the Adafruit Trinket and Trinket Pro. I'm always looking for ways to integrate them into something useful.
Have Fun
LOL! No problem. It really could be cleaned up some ;) I threw that together with my right hand from another sketch I had and flashed it while soldering the board up with my left hand. I didn't know there would be a test. JUST KIDDING!
About DIY Maintenance
RV projects you can tackle on your own with a few friendly pointers.4,352 PostsLatest Activity: Jan 29, 2025