I just did Design Challenge part 3 in Lesson 5 of the Arduino tutorials.
I wrote my own code and it would go through each of the modes fine, but when it got to the wave mode, pressing the button again would not return to the "off" mode.
I tested the code on the site, which of course worked fine.
I noticed that the only difference between the two was that in the wave function I had a delay(500) in my program, while the tutorial had delay(50) in their program.
I changed mine to delay(50) and the code worked fine. Then I changed the code from the tutorial to delay(500) and it had the same problem as mine.
Can anyone explain why this happens? Does the wave function have to run through a certain number of cycles or something? I don't see what in the code would be causing this.