How many tasks can the Arduino UNO do at once?

Hello World!

I know the Arduino UNO can do multiple tasks ( multitasking ) using millis() and interrupts. But how many tasks can it do at once? Cause normally 2 tasks ( even for a simple code ) one is running the code and the second task is to count milliseconds. When it comes to interrupts, Arduino starts a third new task.

Can we have multiple interrupts? If yes or no, how many tasks can the Arduino UNO do at once?

I had one playing 13 tones. How many tasks are you needing?
https://forum.arduino.cc/index.php?topic=179761.0
Youtube video
https://www.youtube.com/watch?v=4c8idXN4Pg0
Only demo'd 8, ran out of buttons. The code was written for 13 using an Atmega1284P which has more IO than a '328P.

If you look at the demo Several Things at a Time you will see that it is blinking 3 LEDs, checking a switch and operating a servo all based on the use of millis()

Note how each function runs very briefly and returns to loop() so the next one can be called. None of the functions tries to complete a task in one call. And there may be dozens of calls to a function before it is actually time for it to do anything.

The limiting factor for the number of tasks will depend on whether the Arduino is fast enough to give the illusion that they are happening at the same time. Tasks that don't take much time and which only happen at long intervals (like once per 5 seconds) won't take up many CPU cycles.

Interrupts are not really a practical way to do multi-tasking on an Arduino. An Interrupt Service Routine (ISR) should complete very quickly (100 microsecs would be a long time) so it cannot contain the code for the task. All it can do is update a variable to let the main program know that the interrupt has happened. The usual exception to this is where you want one of the Hardware Timers to toggle an I/O pin at specific intervals (usually a high frequency) - but that is just a single rather special type of task.

...R

CrossRoads:
I had one playing 13 tones. How many tasks are you needing?
https://forum.arduino.cc/index.php?topic=179761.0
Youtube video
https://www.youtube.com/watch?v=4c8idXN4Pg0

Cool vid...Can the Arduino Handle 4 - 5 tasks at a time?

Robin2:
Interrupts are not really a practical way to do multi-tasking on an Arduino. An Interrupt Service Routine (ISR) should complete very quickly (100 microsecs would be a long time) so it cannot contain the code for the task. All it can do is update a variable to let the main program know that the interrupt has happened. The usual exception to this is where you want one of the Hardware Timers to toggle an I/O pin at specific intervals (usually a high frequency) - but that is just a single rather special type of task.

I didn't know that cause on the internet it said millis() and interrupts for multitasking and when I tried it out it felt like multitasking...Well anyways thanks for letting me know!