Chapter 10: C Structures
PORTD = ~0x02;
break;
break;
PORTD = ~0x08;
break;
PORTD = ~0x10;
break;
rrent state is the value of PORTD. The input is the
tement for the specific joystick input sets the next
t is enclosed in a for(;;){}block, the
known, so the possibilities are finite and
e machine. What could be simpler? (Usually said
x.)
t of the box does a lot of stuff. And it has a lot of
enu state machine, which is
ation
case KEY_NEXT :
case KEY_PREV :
PORTD = ~0x04;
case KEY_MINUS :
case KEY_ENTER :
default:
}
This is a state machine. The cu
joystick position. The case sta
state in PORTD. If this switch statemen
Butterfly’s states and transitions are all
you have yourself a finite stat
right before things get comple
But, of course, the Butterfly ou
state machines controlling its behavior. One is the m
really the core state machine as far as a user is concerned. Here is an illustr
of the Butterfly menu structure: