Non blocking event driven programming for microcontrollers