Back to Parent

int ledPin = D2;
int ledPin2 = D3;

void setup() {
     pinMode(ledPin, OUTPUT);
     digitalWrite(ledPin, LOW);
     pinMode(ledPin2, OUTPUT);
     digitalWrite(ledPin2, LOW);
 
     Particle.function("Red led", ledControl1);
     Particle.function("Orange led", ledControl2);
 
}

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

   if(command == "HIGH"){
      digitalWrite(ledPin, HIGH);
      delay(500);
  } 
	      
   }else if(command == "LOW"){ 
	   state = LOW;
   }else{
	   return -1;
   }

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

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

   if(command == "HIGH"){
      digitalWrite(ledPin2, HIGH);
      delay(500);
  } 
	      
   }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