Find a components range of values for PWM

Hey my first post here and apologies if this is a stupid question. I learned that using PWM i can make a motor spin slower or faster but how would i deduce this range of current a component can take. E.g a LED can be set between 0-255 if not mistaken. Is there perhaps a way to use the serial command to deduce this range of values?

You could either write a slow loop that ramps up and down the duty cycle from 0 to 100%, and report the value to the serial interface, or you could write a simple program to enter the duty cycle via the serial monitor or terminal emulator.

Thanks for this, could you be a little more instructive though, my arduino knowledge is unfortunately rather limited =/

Simple ramp, compiled, but untested.

// simple ramp
const byte PWMpin = 9;
const long STEP_WAIT = 1000;

void setup ()
{
  Serial.begin (115200); 
}
void loop ()
{
  Serial.println (F("Ramping up"));
  for (int i = 0 ; i < 256; i++) {
    setSpeed (i);
  } 

  Serial.println (F("Ramping up"));
  for (int i = 0 ; i < 256; i++) {
    setSpeed (i);
    delay (STEP_WAIT); // normally, I don't like this, but you're not doing anything else
  } 
  Serial.println (F("Ramping down"));
  for (int i = 255 ; i >= 0; i--) {
    setSpeed (i);
    delay (STEP_WAIT);
  } 

}
void setSpeed (int x)
{
  Serial.print (F("Setting "));
  Serial.println (x);
  analogWrite (PWMpin, x);
}

Ah thanks loads man! You sir are a gentleman and a scholar

oops, just noticed the cut-and-paste boo-boo in the print. Ho-hum, I'm sure you got the drift.