

In other words, if we set up as attached code, it also means that, timerIsr() function will be executed every 500ms. The parameter inside Timer1.attachInterrupt(X) is actually the function name that will be called when the defined time is reached. The value inside Timer1.initialize(X) are measured in micro seconds, so 500000 actually means it is 500ms. The function to call for the interrupt, we called it interrupt service routine (ISR) Basically, we need to configure for 2 items only (Thanks to TimerOne libray):Ģ. Next, we need to setup (initialize) our timer. To start using the timer interrupt, we need to include the TimerOne library first, by adding “#include ” at the beginning of our code. The answer is, by using a timer interrupt! (of course, lol) So, how can we blink an LED 500ms ON 500ms OFF, while executing other task at the same time?

Restart you Arduino IDE, after that, you will find TimerOne examples under Files> Examples > TimerOne Extract the TimerOne libray downloaded just now, put it into the “TimerOne” folder created just now.Ĥ. (mine was: C:\Program Files (x86)\Arduino\libraries)ģ.
ARDUINO WHILE LOOP TASK INSTALL
Create a folder name “TimerOne” in the libraries folder from the directories where you install Arduino IDE. Please follow below steps to get the library:Ģ. Assumes you had understand what is polling and what is interrupt from previous post (Polling vs Interrupts) lets begin hands on to include this interrupt feature in your project.
