Timed latching circuit...

Hi guys

I have a quick question. I want to create a 30min latch using a Nano and a momentary push button. The idea is to run a solenoid to water my grass using a Nano and a relay board. But I really want to push the button, and latch the relay for 30min.

Can somebody please help my basic programming knowledge? :o

You've got: 1000 milliseconds in a second. 60 seconds in a minute. 30 minutes in your desired time period. So, you need a pause of 1000 * 60 * 30 milliseconds. Unfortunately, this value is too big to fit in the default "int" datatype, so you must use an "unsigned long" and "unsigned long" arithmetic.

unsigned long waitTime = 1000UL * 60UL * 30UL;

Do you want a simple sketch with - fixed time or - adjustable and - visible countdown on a lcd display for example ?

If only a fixed time is needed it would be very simple to set up. What about the solenoid type (12V, 24V, mains) ?

If mains are involved, do you have the right skills and experience to handle dangerous/fatal voltages?

If you just want a fixed 30min latching circuit, take a look at the good ol' NE555 timer chip (in monostable configuration). Otherwise, take a look at the millis() function. (And use unsigned long, like AWOL suggested.)