Refine state machine

Still unable to get sw2 interrupt working.sw1 interrupt state machine
working fine.