Back to Parent

//Exercise 2
int ledPin = D3; 

void setup() 
{
    pinMode(ledPin, OUTPUT); 
    
    digitalWrite(ledPin, LOW); 
    
    //Register our Particle function here
    Particle.function("Controlling number of blinks", ledControl4);
}    
    

void loop() 
{
    
  
}

//Exercise 2. Controlling the number of times the LED blinks. 
int ledControl4(String command)
{
   int led = command.toInt();
   
   if(led > 0)
   {
       for(int i = 0; i <led; i++)
       {
           digitalWrite(ledPin, HIGH); 
            delay(300);        
            digitalWrite(ledPin, LOW);   
            delay(300);
       }
   }
else
   {
	   return -1;
   }
   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