// name the pins
int ledPin = D2;
int Val = 0;
void setup()
{
// Configure the pins to be outputs
pinMode(ledPin, OUTPUT);
// Initialize both the LEDs to be OFF
digitalWrite(ledPin, LOW);
Particle.function("led", ledControl);
}
void loop()
{
}
int ledControl(String cntblink)
{
Val = cntblink.toInt(); //Use toInt function to turn string command into Int
if(Val <= 0)
{
return -1;
}
else
{
for (int i = 0; i < Val; i++)
{
digitalWrite( ledPin, HIGH );
delay( 500 );
digitalWrite( ledPin, LOW );
delay( 500 );
}
}
// write to the appropriate pin
digitalWrite(ledPin, LOW);
return 1;
}
Click to Expand
Content Rating
Is this a good/useful/informative piece of content to include in the project? Have your say!
You must login before you can post a comment. .