Go Down

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

MikeDeKlerk

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.

Cheers.

ProfePaco

that's very interesting.

Thanks for sharing!

rukna

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.

florinc

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

Go Up