24 hour timer with reset if sensor activated

Hi, i wish to program an Arduino to do the following :

  1. When switched on, start counting for 24 hours
  2. At end of 24 hour count, switch on relay
  3. If an input from a PIR sensor gives a jolt, restart count from beginning

Any suggestions ?

These may help with finding/developing a long period timer.

I used them with a microcontroller to do a thing. The microcontroller did other things while waiting for the 24 hour timer to trigger.

For a relay, I suggest getting an opto-isolated relay module.

#define OutputPin 4
#define InputPin 3

void setup() {
  pinMode(OutputPin, OUTPUT);
}

void loop() {
  delay(86400000UL);  //24 * 60 * 60 * 1000
  digitalWrite(OutputPin, HIGH);
  while(digitalRead(InputPin)==LOW);
}

?..

An Uno does the 16 bit integer thingy. What is the largest number a 16 bit integer can hold?
What is 24*60*60*1000?

Thanks

Thanks. V helpful

1 Like
  1. Move this topic to "programming" - it has nothing at all to do with installation or troubleshooting

  2. don't modify earlier posts, if doing so makes nonsense of subsequent comments

@Jontenoy, your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advise on) your project.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.