I have an RTC and a push button that causes a series of functions.
Just wondering if it is possible to have this button only active during a certain time of the day? Is this possible?
Thanks.
Absolutely it is, if you know your time limits, a simple if statement may work.
If the time is between some hour, and another hour, then read the button state.
Else do nothing
Thankyou
The way I would do it is this: when someone pushes the button, I would read the time. Then if, and only if, the time is during "active" hours, would I perform whatever functions are supposed to be done then.
- Do you know how to make the Arduino read the time from the RTC?
- Do you know how to write an
if
statement that checks whether a number is between two other numbers?
If you can do both of those, then you have the skills you need to make your button active only during certain hours of the day.
I can definitely do the first since I have a code that reads the current time in the serial monitor however the second I'm a little unsure with. I'm extremely new to Arduino but after that description may have what is necessary to do it. Thanks!
You will need this: if - Arduino Reference
This will also be helpful: && - Arduino Reference
I think you will want the test to look something like this:
if ((h>=9) && (h<17)) {
// do something;
}
Okay thanks!
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.