Back to Parent

// name the pins
int ledPin = D2;

void setup()
{
   // Configure the pins to be outputs
   pinMode(ledPin, OUTPUT);

   // Initialize both the LEDs to be OFF
   digitalWrite(ledPin, LOW);
   
    //Register our Particle function here
   Particle.function("ledb", ledBlink);
}
void loop()
{
   // Nothing to do here
}
int ledBlink(String cntInput)
{
   int cnt = atoi(cntInput);
   if  (cnt <= 0){
       return -1;
   }
   for(int i = 0; i < cnt; i++){
           digitalWrite(ledPin, HIGH);
           delay(500);
           digitalWrite(ledPin, LOW);
           delay(500);
       }
   // turn the LED off
   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!

0