Serial communication and atoi() trouble

Thanks, guys! Both of these solutions work nicely

Also, if anyone else is curious this is the code I used to extract the actual integers from the received and parsed array of chars. So if the packet sent to the Arduino was ''sm1x150e" buffer contains "m1x150" (using zoomkat's code from above) and now two sub-arrays need to be created. These must end with the '\0' character for atoi() to work.

      char temp1[]={buffer[1],'\0'};
      char temp2[]={buffer[3],buffer[4],buffer[5],'\0'};
      dir=atoi(temp1);
      pwm=atoi(temp2);