Pages: [1]   Go Down
Author Topic: still run functions while in delay  (Read 659 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 3
Posts: 188
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

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

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Full Member
***
Karma: 3
Posts: 188
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


thanks Nick!
Logged

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

Offline Offline
Full Member
***
Karma: 3
Posts: 188
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
« Last Edit: March 06, 2013, 12:23:32 am by hilukasz » Logged

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

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16497
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

California
Offline Offline
Faraday Member
**
Karma: 82
Posts: 3123
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16497
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Offline Offline
Full Member
***
Karma: 3
Posts: 188
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley-razz http://arduino.cc/en/Reference/UnsignedLong
Logged

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

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

unsigned int is not the same thing as unsigned long
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

You said:

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

Offline Offline
Full Member
***
Karma: 3
Posts: 188
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: March 06, 2013, 11:01:55 pm by hilukasz » Logged

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

Pages: [1]   Go Up
Jump to: