Do Button Call Spark Function Errors with Servo Library

I have an IFTTT do button calling the test function in the code below. It compiles, and I can flash the core, but if I add the servo stuff, all that happens is that the breathing cyan light blinks a little and I get a notice from IFTTT that there was an error. I can successfully call functions if I’m doing other things besides using the servo library. If I try to do some serial debugging by putting a print statement in the function handler, nothing prints, so it’s not getting called. Any thoughts?

Servo myServo;

bool move = false;

void setup() {
    myServo.attach(D0);
    Spark.function("test", test);
    myServo.write(90);
}

void loop() {
    if(move == true){
        myServo.write(180);//choose correct angle
        delay(1000);
        myServo.write(90);//choose correct angle
        move = false;
    }
}

int test(String args){
    move = true;
}

Does it work better if you add a return(0); before the end of the test function?

I would have thought that gcc would give you a compile error but I read that the C spec allows for no return values and the value actually returned is implementation specific.

You could also try my servo example here:

[EDIT] one other note: servos take a lot of power! Mine did not like USB power but worked great on a separate high-current supply.

I added return 0; to the function handler, and I also used external 5V power for the servo. Still getting the same result. I have gotten this servo to work without using the IFTTT Do button. P.S. If I call the function using CURL, it works. I can call other functions using the do button, but I can’t if there’s servo code in there, so it seems.

Ok, maybe it’s not the servo code. This won’t work now either:

void setup() {
    Spark.function("test", test);
}

void loop() {

}

int test(String args){
    RGB.control(true);
    RGB.color(255,0,0);
    delay(5000);
    RGB.control(false);
    return 0;
}

Works fine using CURL. Do button broken on functions?

Sometimes problems come up with IFTTT that can cured by either waiting a while (hours) or renaming the function on your core (“test2”) so the IFTTT code resets itself.

Can you try renaming the function to something else and see?

Ok, renamed function to test3, revised the do button recipe. Again, after pressing the do button, the spark LED will flash a few times and go back to breathing cyan, and I’ll get an error message from IFTTT.

OK that must be the RGB control version above. The delay of 5 seconds before returning a value to the cloud is a problem. It is much better to treat the Spark function like an interrupt handler and do the minimum work there, but set a variable so that more work is done in loop(), like you had for the servo.

did all that, nothing worked. failed a couple of times in front of my classes. tonight, however, i prevailed. i think it might have something with the do button’s default to sending data to the function that isn’t handled? this is conjecture at this point, but i used the same recipe, but just deleted the args being passed to the function, and everything worked. the servo responded to its call. i’d need to sit down and focus to really be sure this was the case…