Offline
Full Member
Karma: 2
Posts: 138
|
 |
« on: March 05, 2013, 10:44:17 pm » |
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
Melbourne, Australia
Offline
Shannon Member
Karma: 218
Posts: 13896
Lua rocks!
|
 |
« Reply #1 on: March 05, 2013, 10:59:27 pm » |
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 9
|
 |
« Reply #2 on: March 05, 2013, 11:10:17 pm » |
Perfect! Thanks, that's exactly what I was looking for.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Full Member
Karma: 2
Posts: 138
|
 |
« Reply #3 on: March 05, 2013, 11:28:14 pm » |
|
|
|
|
|
Logged
|
for(i = 0, i < 820480075, i++){ Design(); Code(); delay(1000); } // hellowoo.com
|
|
|
|
Offline
Full Member
Karma: 2
Posts: 138
|
 |
« Reply #4 on: March 06, 2013, 12:21:52 am » |
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
Brattain Member
Karma: 279
Posts: 15309
Measurement changes behavior
|
 |
« Reply #5 on: March 06, 2013, 12:24:54 am » |
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
Melbourne, Australia
Offline
Shannon Member
Karma: 218
Posts: 13896
Lua rocks!
|
 |
« Reply #6 on: March 06, 2013, 01:24:26 am » |
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
Edison Member
Karma: 37
Posts: 1827
|
 |
« Reply #7 on: March 06, 2013, 01:32:41 am » |
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
Brattain Member
Karma: 279
Posts: 15309
Measurement changes behavior
|
 |
« Reply #8 on: March 06, 2013, 01:50:32 am » |
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
Full Member
Karma: 2
Posts: 138
|
 |
« Reply #9 on: March 06, 2013, 10:35:40 pm » |
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 http://arduino.cc/en/Reference/UnsignedLong
|
|
|
|
|
Logged
|
for(i = 0, i < 820480075, i++){ Design(); Code(); delay(1000); } // hellowoo.com
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 218
Posts: 13896
Lua rocks!
|
 |
« Reply #10 on: March 06, 2013, 10:42:20 pm » |
unsigned int is not the same thing as unsigned long
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 218
Posts: 13896
Lua rocks!
|
 |
« Reply #11 on: March 06, 2013, 10:44:34 pm » |
See this: http://arduino.cc/en/Reference/UnsignedIntYou said: ... since I am using an Unsigned Integer in this example ...
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Full Member
Karma: 2
Posts: 138
|
 |
« Reply #12 on: March 06, 2013, 10:59:29 pm » |
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
|
|
|
|
|