Back to Parent

int ledPin1 = D2;
int ledPin2 = D3;
int ledValue = 0;

void setup() {
    Particle.function("led1", ledControl);
    Particle.function("led2", led2Control);
    Particle.variable("brightness", ledValue);
    pinMode(ledPin1, OUTPUT);
    pinMode(ledPin2, OUTPUT);


}



int ledControl(String command)
{
   int state = LOW;

   // find out the state of the led
   if(command == "HIGH"){
	   state = HIGH;
   }else if(command == "LOW"){ 
	   state = LOW;
   }else{
	   return -1;
   }

   // write to the appropriate pin
   digitalWrite(ledPin1, state);
   return 1;
}

int led2Control(String command)
{
   int state = LOW;

   // find out the state of the led
   if(command == "HIGH"){
	   state = HIGH;
   }else if(command == "LOW"){ 
	   state = LOW;
   }else{
	   return -1;
   }

   // write to the appropriate pin
   digitalWrite(ledPin2, state);
   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