Go Down

Topic: Time specific programs (Read 311 times) previous topic - next topic

sausages

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

PaulS

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?

sausages

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?

PaulS

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: [Select]
ifInow.hour() >= 13 && now.hour() <= 15)
{
   // Do the 1:00 to 3:00pm stuff...
}

PeterH


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.
I only provide help via the forum - please do not contact me for private consultancy.

sausages


bubulindo



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... :)
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).

Go Up