 {
     digitalWrite(indicator, running);
 }
+
+//!  @brief  :  receive the command from pc.
+void build(String& cmd)
+{
+  while (Serial.available()) 
+  {
+    delay(3);  //delay to allow buffer to fill 
+    if (Serial.available() > 0) 
+    {
+      char c = Serial.read();  //gets one byte from serial buffer
+      cmd += c; //makes the string readString
+    } 
+  }
+}

//!  struct storing the state information
class State
{
  public:  
  unsigned spd;
  unsigned steps;
  boolean  running;    
  boolean  cw;
};

void wave(const State* state);
void full(const State* state);
void half(const State* state);
void micr(const State* state);
void pwm(unsigned pin, unsigned period, unsigned duty);
void indicate(boolean running);

void setup() 
{                

void loop() 
{
  String cmd;
  build(cmd);

  if(cmd.length() > 3)
  {    
    State state(cmd);
  
    switch (state.mode)
    {
      case 1  :  wave(&state);  break;
      case 2  :  full(&state);  break;
