working my way slowly through the o'reilly book. i have asked about this recently but in this case (as an experiment) it seems that the analog function doesn't just continue regardless of what the rest of the programme is doing.
an led connected to pwm output 9 will grow brighter and dim but not not totally go dark , there will a small amount of current flowing. the led on the board (13) will go on for 5 seconds but the led on 9 will not continue fluctuating it will wait until the led on 13 has turned off. by rights the arduino should understand i want the led to fluctuate reagardless of what the rest of the programme is doing?
the 5000 delay is part of a programme designed to turn a light on for 5 seconds and then switch it off.
interestingly enough as mentioned the led doesn't ever switch off totally. by the time the 5 second delay comes into play the led has already started growign brighter again.
if a remove the 5 second delay on off part of the programme everything is "normal" but i've got no proof that the pwm output is ignoring the rest of the programme and just doing what it has been told to do.
the delay command actually pauses the whole chip from doing anything, and thus beyond the simplest linear program, you would never want to use delay. so if you read your program in a linear way, you see that the pwm led lights up and then dims (but never reaches 0 because of the way you set up the for loop) and then the pin 13 turns on, waits 5 sec, then turns off and the program then loops back to the pwm for loops. you would have to setup a counter variable and use if statements or look at a time variable (millis(); ) to have the two things turn on and off independently of each other. hope that helps...
i was really experimenting with the pwm programme in the book the only thing i did was add the delay to spice things up and see what it would do and if the pwm output would continue.