Pages: [1]   Go Down
Author Topic: Time specific programs  (Read 284 times)
0 Members and 1 Guest are viewing this topic.
Isle of Wight, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 7
I Like Robots.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi! I have a problem, I need to run a program only between certain hours.

Is it possible only to run the program from 1pm-3pm every day? I have searched for a long time and can find no help on the internet, maybe one of you might know how this is possible. It would be really good if you could help

Thanks
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Without a real time clock, the Arduino has no idea what time it is. With a real time clock, what you want to do is trivial. Do you have one?
Logged

Isle of Wight, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 7
I Like Robots.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No I don't, this is at the moment still an Idea- I am finding out about things before I build, but if necessary I will buy a clock as well as the other things, how would this work?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
how would this work?
Depends on the particular RTC and library. With a DS1307, there is a method to get the time, and then the time object has methods to get hours, minutes, seconds, etc.

Code:
ifInow.hour() >= 13 && now.hour() <= 15)
{
   // Do the 1:00 to 3:00pm stuff...
}
Logged

UK
Offline Offline
Shannon Member
****
Karma: 222
Posts: 12549
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is it possible only to run the program from 1pm-3pm every day?

Either give your Arduino a real-time clock and write a sketch that only does stuff during the hours you want, or get an ordinary domestic timer and set that to turn on during the hours you want, use that to power a wall wart that powers the Arduino.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Isle of Wight, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 7
I Like Robots.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you so much!
Logged

'round the world...
Offline Offline
Faraday Member
**
Karma: 42
Posts: 3223
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Is it possible only to run the program from 1pm-3pm every day?
or get an ordinary domestic timer and set that to turn on during the hours you want, use that to power a wall wart that powers the Arduino.

A fine example of thinking outside the box... smiley
Logged

Eu não sou o teu criado. Se respondo no fórum é para ajudar todos mediante a minha disponibilidade e disposição. Responder por mensagem pessoal iria contra o propósito do fórum e por isso evito-o.
Se realmente pretendes que eu te ajude por mensagem pessoal, então podemos chegar a um acordo e contrato onde me pagas pela ajuda que eu fornecer e poderás então definir os termos de confidencialidade do meu serviço. De forma contrária toda e qualquer ajuda que eu der tem de ser visível a todos os participantes do fórum (será boa ideia, veres o significado da palavra fórum).
Nota também que eu não me responsabilizo por parvoíces escritas neste espaço pelo que se vais seguir algo dito por mim, entende que o farás por tua conta e risco.

Dito isto, mensagens pessoais só se forem pessoais, ou seja, se já interagimos de alguma forma no passado ou se me pretendes convidar para uma churrascada com cerveja (paga por ti, obviamente).

Pages: [1]   Go Up
Jump to: