Can You help me with this. I need to run this code in the backround.
I need to run this code in the backround from the rest the code is at the very bottom.
delay(3600000);//3600000
hunger++;
restroom++;
happiness--;
help_code.ino (13.7 KB)
Can You help me with this. I need to run this code in the backround.
I need to run this code in the backround from the rest the code is at the very bottom.
delay(3600000);//3600000
hunger++;
restroom++;
happiness--;
help_code.ino (13.7 KB)
Your code does not download. Attache the code the way told in advices like "How to use this forum", using code tags.
Sxxy-panda999:
I need to run this code in the backround.
delay(3600000);//3600000
Delays that long shouldn't be used, because delay() is blocking code.
The code waits there until the delay time has passed.
Have a look at the BlinkWithoutDelay example in the IDE, to manage time without blocking.
Incomplete example attached.
Leo..
unsigned long currentMillis, previousMillis;
const unsigned long interval = 3600000;
void setup() {
}
void loop() {
currentMillis = millis(); // get current time
if (currentMillis - previousMillis >= interval) { // time for action?
hunger++;
restroom++;
happiness--;
previousMillis = currentMillis; // start new period
}
}
This line causes the Arduino to be brain dead and unresponsive for one hour.
delay(3600000);//3600000
Can you explain why that needs to run in the "backround"?
Wawa:
Delays that long shouldn't be used, because delay() is blocking code.
The code waits there until the delay time has passed.Thank you it works perfectly