This is does not directly answer your question, but if you are trying to control your project via text commands over a serial interface I have developed a library that might interest you.
Its called CommandLine and gives you a unix or dos like command line interface on your serial port or any device that implements the Arduino Stream interface.
You can get the release from http://dl.dropbox.com/u/8923652/CommandLine-1.0.zip or follow the project on Github at GitHub - hackerjones/arduino-commandline: Command line processor for Arduino
Cheers,
Mark