Go Down

Topic: still run functions while in delay (Read 1 time) previous topic - next topic

hilukasz

seem to have a problem that while a function is running which has some delays and digitally increments the brightness of an LED it seems I cannot run anything in between. is there a way to check for example, a button press, while something is in a delay or being incremented?
for(i = 0, i < 820480075, i++){ Design(); Code(); delay(1000); } // hellowoo.com

Nick Gammon

Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Xnor


http://www.gammon.com.au/blink


Perfect!
Thanks, that's exactly what I was looking for.

hilukasz

for(i = 0, i < 820480075, i++){ Design(); Code(); delay(1000); } // hellowoo.com

hilukasz

#4
Mar 06, 2013, 06:21 am Last Edit: Mar 06, 2013, 06:23 am by hilukasz Reason: 1
ok since I am using an Unsigned Integer in this example which can hold a decent count (4,294,967,295) is that a concern of the program crashing? (this thing might be on for several days) Is there a standard practice of reseting the count when it gets to a certain value? that seems like the likely solution...
for(i = 0, i < 820480075, i++){ Design(); Code(); delay(1000); } // hellowoo.com

retrolefty


ok since I am using an Unsigned Integer and that can hold a decent count (4,294,967,295) is that a concern of the program crashing? Is there a standard practice of reseting the count when it gets to a certain value? that seems like the likely solution...


No concerns. As Nick told in the tutorial as long as you arrange your elapsed time testing calculations as a subtraction there is no hazards to deal with.

Lefty

Nick Gammon


ok since I am using an Unsigned Integer in this example which can hold a decent count (4,294,967,295)


No, it won't. 65535.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Arrch


ok since I am using an Unsigned Integer in this example which can hold a decent count (4,294,967,295) is that a concern of the program crashing? (this thing might be on for several days) Is there a standard practice of reseting the count when it gets to a certain value? that seems like the likely solution...


ints are 16-bit

lonbs are 32-bit.

retrolefty



ok since I am using an Unsigned Integer in this example which can hold a decent count (4,294,967,295) is that a concern of the program crashing? (this thing might be on for several days) Is there a standard practice of reseting the count when it gets to a certain value? that seems like the likely solution...


ints are 16-bit

lonbs are 32-bit.


LOL. lonbs, Is that one of those fancy new C++ data types?

hilukasz



ok since I am using an Unsigned Integer in this example which can hold a decent count (4,294,967,295)


No, it won't. 65535.


someone should fix the arduino documentation then :P http://arduino.cc/en/Reference/UnsignedLong
for(i = 0, i < 820480075, i++){ Design(); Code(); delay(1000); } // hellowoo.com

Nick Gammon

unsigned int is not the same thing as unsigned long
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Nick Gammon

See this: http://arduino.cc/en/Reference/UnsignedInt

You said:

Quote

... since I am using an Unsigned Integer in this example ...
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

hilukasz

#12
Mar 07, 2013, 04:59 am Last Edit: Mar 07, 2013, 05:01 am by hilukasz Reason: 1

See this: http://arduino.cc/en/Reference/UnsignedInt

You said:

Quote

... since I am using an Unsigned Integer in this example ...



ooo, you're right. had that pulled up 2am last night when I was reading it. doh. guess I was referring to the tutorial though, it uses a UL or unsigned long. But I see better now how it is used.
for(i = 0, i < 820480075, i++){ Design(); Code(); delay(1000); } // hellowoo.com

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy