Go Down

Topic: Multithreading with Arduino Uno/Mega (Read 4442 times) previous topic - next topic


Hi All,

Multithreading / multitasking in general is very useful. You can run multiple things 'simultaneously' while keeping your code nicely seperated (no spaghetti code).
I have attached a working example (I compiled with toolchain of Atmel Studio 6).

It runs two threads, prints out something over serial connection and blinks the onboard led. It uses AtomThreads (http://atomthreads.com/). It uses a preemptive schedular (apparently).
NOTICE: AtMega2560 has port 7 tied to the on board led instead of port 5. (So change PORTB ^= (1 << 5); to PORTB ^= (1 << 7); for arduino mega).

Hopefully someone finds this useful.



that's very interesting.

Thanks for sharing!


Just started looking into multi-threading when I stumbled upon your post. Thanks for sharing! Will give it a shot with my Mega.

Only downside is that the Atmel Studio runs on a Windows platform and I just got comfortable using the Arduino IDE on my OSX :) No big deal tho.


Why would you use multi-threading on Arduino?
Do you see a practical application for it?

Go Up