If you need multiple tasks to occur at the same time, you cannot use delay().įor most projects you should avoid using delays and use timers instead. Blocking functions prevent a program from doing anything else until that particular task is completed. When you do delay(1000) your program stops on that line for 1 second.ĭelay() is a blocking function. This number represents the time in milliseconds the program has to wait until moving on to the next line of code. It accepts a single int number as an argument. This function is pretty straightforward to use. You should be familiar with the delay() function as it is widely used. Instead of using a delay() function that blocks your code and doesn’t allow you to do anything else for a determined number of seconds, we should use a timer. We want the LED to stay on for a predetermined number of seconds after motion is detected. In this example we’ll also introduce timers.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |