Task scheduling is a transformative way to write maintainable code for Arduino and other AVRs. No more spaghetti code. C++ tutorial.