Adding a Delay?



I have a program that plays notes and flashes the LEDs. But even though there is a duration to the notes, they all play (and the lights flash) instantaneously. I can’t seem to find any sort of delay or wait. Any help would be appreciated.


Hi Eric,

It sounds like you might want to use the “setTimeout” block in the “Control” drawer. It lets you delay code for a certain number of milliseconds.



That helped somewhat. It also made me rethink my program.

It seemed like I had to keep increasing the millisecond delay as it went along, instead of being able to put the same amount of delay for each block. I guess I’ll have to experiment with it some more.

Thanks for your help.


Hi Eric,

Yes, it’s not exactly a delay in that it pauses the program for a particular amount of time. It schedules the code to run after a certain number of milliseconds, but the rest of the code continues to run after it gets scheduled. You will have to schedule things for different lengths of timeout if you don’t want them to happen at the same time.



Glad I found this forum, I was able to make a project with this help! Thought I should share incase the example code can help anyone else.


That’s amazing! I just played it in the Seattle office, and everyone loved it. :slight_smile:



:grinning: Happy you guys enjoyed it. We did not have quite enough time to finish unit 6 this semester, so we are going to end with this project.