interrupt routine embedded in main instead to solve conflict with nilRTOS