better working version of control code

placed state switcher in switch-case format for clarity. added e-stop,
manual, and status cases