Below is the code that loaded on core:
// -----------------------------------
// Controlling LEDs over the Internet
// -----------------------------------
// name the pins
int led1 = D7;
int led2 = D1;
// This routine runs only once upon reset
void setup()
{
//Register our Spark function here
Spark.function("led", ledControl);
// Configure the pins to be outputs
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
// Initialize both the LEDs to be OFF
digitalWrite(led1, HIGH);
digitalWrite(led2, LOW);
}
// This routine loops forever
void loop()
{
// Nothing to do here
}
// This function gets called whenever there is a matching API request
// the command string format is l<led number>,<state>
// for example: l1,HIGH or l1,LOW
// l2,HIGH or l2,LOW
int ledControl(String command)
{
int state = 0;
//find out the pin number and convert the ascii to integer
int pinNumber = command.charAt(1) - '0';
//Sanity check to see if the pin numbers are within limits
if (pinNumber < 0 || pinNumber > 1) return -1;
// find out the state of the led
if(command.substring(3,7) == "HIGH") state = 1;
else if(command.substring(3,6) == "LOW") state = 0;
else return -1;
// write to the appropriate pin
digitalWrite(pinNumber, state);
return 1;
}
This is the curl sytax that I am using to turn OFF led on D7 throu 'NET
curl - k "https://api.spark.io/v1/devices/xxxxxxxx/led -d access_token=xxxxxxxxxx-d params=l1,HIGH"
I have also tried http://jflasher.github.io/spark-helper/
It does not turn OFF the LED on D7. Why? HELP.