     int result = -1;
 
     if (value.length() > 0) {
-        gBrightness = (float)value.toInt() / 100.0;
+        float brightnessFloat = value.toFloat();
+        gBrightness = value.toFloat() / 100.0;
         result = value.toInt();
     }
 

boolean gPowerState = true;
float gHue = 1;
float gSaturation = 1;
float gBrightness = 1;

void setup()
{
   RGB.control(true);

   updateLED();

   //Exposed internal functions as cloud API
   Spark.function("powerState", powerState);
   Spark.function("hue", hue);
   Spark.function("saturation", saturation);
   Spark.function("brightness", brightness);
}

/* Cloud methods */

int powerState(String value) {
    int result = -1;

    if (value.length() > 0) {
        gPowerState = (value.toInt() == 1);
        result = gPowerState;
    }

    updateLED();

    return result;
}

int hue(String value) {
    int result = -1;

    if (value.length() > 0) {
        gHue = (float)value.toInt() / 100.0;
        result = hue.toInt();
    }

    updateLED();

    return result;
}

int saturation(String value) {
    int result = -1;

    if (value.length() > 0) {
        gSaturation = (float)value.toInt() / 100.0;
        result = value.toInt();
    }

    updateLED();

    return result;
}



/* LED color manipulation methods */

void hslToRgb(float h, float s, float l){
    float tempR, tempG, tempB;
    int r, g, b;

    if(l == 0){
        ledControl(0,0,0);
    }
    if(s == 0){
        r = g = b = l; // achromatic
    }else{
        float q = l < 0.5 ? l * (1.0 + s) : l + s - l * s;
        float p = 2.0 * l - q;
        tempR = hue2rgb(p, q, h + 1.0/3.0);
        tempG = hue2rgb(p, q, h);
        tempB = hue2rgb(p, q, h - 1.0/3.0);
    }
    
    r = round(tempR * 255);
    g = round(tempG * 255);
    b = round(tempB * 255);

    ledControl(r,g,b);
}

float hue2rgb(float p, float q, float t){
    if(t < 0.0){ 
        t += 1.0;
    }
    if(t > 1.0){
        t -= 1.0;
    }
    if(t < 1.0/6.0){
        return p + (q - p) * 6.0 * t;
    }
    if(t < 1.0/2.0) {
        return q;
    }
    if(t < 2.0/3.0) {
        return p + (q - p) * (2.0/3.0 - t) * 6.0;
    }
    return p;
}

void ledControl(int redValue, int greenValue, int blueValue)
{
   // write the mixed color
   analogWrite(redPin, redValue);
   analogWrite(greenPin, greenValue);
   analogWrite(bluePin, blueValue);
}

// Only update if turned on
void updateLED() {
    if (gPowerState) {
        hslToRgb(gHue, gSaturation, gBrightness);
    } else {
        ledControl(0,0,0);
    }
}
