Back to Parent

//Exercise 3
int ledPin3 = D3; 
int ledPin2 = D2; 

void setup() 
{
    pinMode(ledPin3, OUTPUT); 
    pinMode(ledPin2, OUTPUT); 
    
    digitalWrite(ledPin3, LOW); 
    digitalWrite(ledPin2, LOW); 
    
    //Register our Particle function here
    Particle.function("RED BLINKS", ledControl3);
    Particle.function("YELLOW BLINKS", ledControl2);
}    
    

void loop() 
{
    
  
}

int ledControl3(String command)
{
   int led3 = command.toInt();
   
   if(led3 > 0)
   {
       for(int i = 0; i <led3; i++)
       {
           digitalWrite(ledPin3, HIGH); 
            delay(300);        
            digitalWrite(ledPin3, LOW);   
            delay(300);
       }
   }
else
   {
	   return -1;
   }
   return 1;
}

int ledControl2(String command)
{
   int led2 = command.toInt();
   
   if(led2 > 0)
   {
       for(int i = 0; i <led2; i++)
       {
           digitalWrite(ledPin2, HIGH); 
            delay(300);        
            digitalWrite(ledPin2, 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