Brushless motor control via Serial

Hi,

I'm trying to drive a brushless motor via an ESC which worked fine, now I am trying to have it read data from serial and control the motor with the serial data but I'm having a problem.

After it inits it sits there idle, then after sending a value to the com port it goes to the speed for the duration of Delay() but then no more.

The code is messy (I haven't done a whole lot with the Arduino) as it's got bits and pieces from different projects/posts

// this uses the Arduino servo library included with version 0012

// caution, this code sweeps the motor up to maximum speed !
// make sure the motor is mounted securily before running.

#include <Servo.h>
int serspeed = 0;

Servo myservo;

void arm(){
  // arm the speed controller, modify as necessary for your ESC  
  setSpeed(30);
  delay(1000); //delay 1 second,  some speed controllers may need longer
}

void setSpeed(int speed){
  // speed is from 0 to 100 where 0 is off and 100 is maximum speed
  //the following maps speed values of 0-100 to angles from 0-180,
  // some speed controllers may need different values, see the ESC instructions
  int angle = map(speed, 0, 100, 0, 180);
  myservo.write(angle);    
}

void setup()
{
  myservo.attach(12);
  arm();  
  Serial.begin(9600);
  pinMode(serspeed, OUTPUT);
}


void loop()
{
    serspeed = Serial.read();
    setSpeed(serspeed);
    delay(1000);
  }

Hi,
I think you need to check if Serial has data available. Otherwise your SerialRead may return 0??

Let us know!

It has to have some data because the first value I enter starts it up for the delay period.
I'm using the serial monitor in arduino. How can I check to make sure it is sending?