Hi all.
i need to do a counter, ex:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
for 5 minutes.
I need reverse counting
Hi all.
i need to do a counter, ex:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
for 5 minutes.
I need reverse counting
Take a look at millis - that'll help you establish how much time has passed.
i not need to now how much time has passed. i need to do for 5 minutes.
sinsetsin:
i not need to now how much time has passed. i need to do for 5 minutes.
Rubbish.
You need to know that 5 minutes has passed
Look at Using millis() for timing. A beginners guide, and look at the BlinkWithoutDelay example in the IDE.
Indeed rubbish. If you're counting, how do you know how much time has passed if you don't know how long each count takes?
So you need to turn the LED on then 5 minutes later turn it off. The way you know when to turn it off is to check the time until you know that 5 minutes has passed.
If you really don't need the Arduino to be doing anything else at all for that 5 minutes you can use delay() to do the checking for you.
digitalWrite(ledPin, HIGH);
delay(300000); // do nothing for 5 minutes
digitalWrite(ledPin, LOW);
But it's usually better to use millis(). You can use that to time things without completely stopping everything else from working.
Steve
Thank you for help. You are very nice.