Arduino microcontrollers are a beginner friendly and low cost platform for electronics and programming. They’re great for simple control tasks like

Multitasking with Arduino – Millis(), RTOS & More!

submited by
Style Pass
2021-05-12 04:13:37

Arduino microcontrollers are a beginner friendly and low cost platform for electronics and programming. They’re great for simple control tasks like blinking an LED, but how much can we stretch the potential of a single Arduino? In other words, is multitasking with Arduino possible? If you’ve learnt some basic Arduino Programming and want to take it to the next level, this article is definitely for you!

Before we get into proper Arduino multitasking, we need to talk about different methods of keeping time, starting from the very popular delay() function. Let’s first take a look at the definition of the function from the official Arduino documentation.

An unfortunate caveat of the delay() function is that it is a blocking delay. Let me explain. Through the duration of a delay() function call, the CPU of our Arduino is kept busy. This means it can’t respond to sensor inputs, perform any calculations, or send any outputs.

To better explain the implications of this behaviour, let’s look at an example. Taking the blinky example from the same page, our Arduino code to blink an LED at regular intervals with the use of the delay() function might look like this.

Leave a Comment