void setup( void ) { P1DIR = 0b000110000; P1OUT = 0b000000000; // Turn the motor off (bit 4 off, bit 5 off) } enum { OFF, LEFT, RIGHT } which; void loop( void ) { if( which == OFF ) { P1OUT = 0b00010000; // Turn the motor on (bit 4 on, bit 5 off) which = LEFT; } else if( which == LEFT ) { P1OUT = 0b00100000; // Turn the motor on (bit 4 off, bit 5 on) which = RIGHT; } else { P1OUT = 0b00000000; // Turn the motor off (bit 4 off, bit 5 off) which = OFF; } delay( 2000 ); }