state=0;for(;;){ switch(state) { case 0:/* ждём 0 */ if(PIND&(1<<PD0)){} else {state=1;} break; case 1:/* ждём 1 */ if(PIND&(1<<PD0)) { state=0; StartTx(); } break; }}