Hi,
Here's a link to finite state machine programming. http://www.emesystems.com/BS2fsm.htm It's based on the BasicStamp but should be close enough to work with PBP.

/Henrik Olsson.