Jump to content

Arduino 20 minute Script


G+_Sean Miller
 Share

Recommended Posts

Arduino 20 minute Script

I want to design an Arduino (maybe a Raspberry Pi, but I want it to be more robust and fast booting) that will run a script over 20 minutes.

At 1 minute activate these relays, at 2 minutes activate these other relays, etc.

The script would be activated by pressing a start button, so not based on time-of-day. I'd need the script to be pausable, resettable, etc.

 

My question is what is the best way to walk through a script over twenty minutes and still keep it interruptible and pausable. Would a RTC jerry rigged to not keep time-of-day work? How would I pause it?

Thank you very much for your time.

Sean

Link to comment
Share on other sites

If I don't have a clear understanding of what's needed, I usually start with pseudo code. Then add real code.

 

define/init variables & constants

 

if a Button Pushed then

startTime = millis()

 

if millis() - startTime > 1000 then

relay1 = on

else

relay1 off

 

or maybe

 

relay1 = millis() - startTime > 1000

 

So this is where I'd start but the best thing is just jump in, the water's fine. :)

Link to comment
Share on other sites

The Arduino's built in clock may be accurate enough for your needs. I haven't done too much testing, but in the little bit that I have done it seemed adequate.

 

I used an nRF24L01 chip to talk to a Pi and get the time, then used AES encryption to send the time back to the Pi. All just proof of concept stuff and I only let it run for a few days. But it worked!

 

I agree that using variables to store your times and letting the loop keep running is better than pausing for 20 minutes, or whatever. I used that method a few years ago for a refrigerator door alarm (tones at 30 and 45 seconds open then constant beep at 60).

Link to comment
Share on other sites

 Share

×
×
  • Create New...