Pages: 1 [2]   Go Down
Author Topic: Help With DO/While Statement  (Read 1034 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 1
Posts: 209
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You will continue having to hold the switch pressed until all the delay() calls are done, unless you get rid of them. Look at, understand, and embrace the blink without delay example, and banish the delay() function from your repertoire.

I am working on it.  So all the delay's down in the void looP() need to go bye, bye?
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 615
Posts: 49409
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
So all the delay's down in the void looP() need to go bye, bye?
The delay(10) for debouncing can stay. The rest have got to hit the road.
Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 209
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
So all the delay's down in the void looP() need to go bye, bye?
The delay(10) for debouncing can stay. The rest have got to hit the road.

I am having a real hard time understanding how to incorporate this in to my code.

Do you know of a better example/tutorial I could look at. also can anyone recommend a good book the explains the code better. The books i have seen so far show you how to do things but not why you do them.
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 615
Posts: 49409
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I am having a real hard time understanding how to incorporate this in to my code.
You have a watch, a pad of paper and a pencil. Explain how YOU would turn the lights on and off, and move the servo, every two hours.

The millis() function replaces the watch. Variables replace the paper and pencil. The methodology stays the same.
Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 209
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


The millis() function replaces the watch. Variables replace the paper and pencil. The methodology stays the same.

Ok, I found a few good examples of the blink with out delay sketch and I have a good understanding of the millis() function.

What I can't wrap my mind around is how do use it in my code. (I am not this dumb I promise).

I think I am over thinking it. but it's driving me crazy.

 
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 615
Posts: 49409
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I think I am over thinking it. but it's driving me crazy.
List the steps that you would follow, if the Arduino was broken, and you needed to do the job for a while.

If mode is 1, some activities need to be performed. Perform the first one, and record when that happened. Periodically, if mode is still 1, determine if it is time to perform the next activity. If it is, perform that activity and record when that activity was performed.

Obviously, you need to keep track of what activity was last performed, or which is next to be performed. You need to keep track of when the last activity happened, and how long it is to be until the next activity. The time to the next activity clearly depends on which activity was last performed.
Logged

Pages: 1 [2]   Go Up
Jump to: