Trying to transfer flashing code to a state machine