Пример скетча многопоточности в Arduino с использованием RGB светодиода (как их подключить см. здесь) и библиотеки Thread.h
#include <Thread.h> const int pin_led_red = A0; const int pin_led_green = A1; Thread led_red_stream = Thread(); Thread led_green_stream = Thread(); void setup() { pinMode(pin_led_red, OUTPUT); pinMode(pin_led_green, OUTPUT); led_red_stream.onRun(led_red); led_red_stream.setInterval(500); led_green_stream.onRun(led_green); led_green_stream.setInterval(500); } void loop() { if (led_red_stream.shouldRun()) led_red_stream.run(); if (led_green_stream.shouldRun()) led_green_stream.run(); } void led_red() { static bool led_state = false; led_state = !led_state; digitalWrite(pin_led_red, led_state); } void led_green() { static bool led_state = true; led_state = !led_state; digitalWrite(pin_led_green, led_state); } /* void led(int led_state, const int port) { if(led_state==LOW) { digitalWrite(port, LOW); led_state=HIGH; } else { digitalWrite(port, HIGH); led_state=LOW; } } */