// Cloud Control: Exercise 3
// declare a variable and load it with value
int ledPinRed = D2;
int ledPinBlue = D5;
void setup() {
pinMode(ledPinRed, OUTPUT);
pinMode(ledPinBlue, OUTPUT);
digitalWrite(ledPinRed, LOW);
digitalWrite(ledPinBlue, LOW);
Particle.function("led", ledControl);
}
void loop() {
}
int ledControl(String command)
{
int state = LOW;
if(command =="Red"){
digitalWrite(ledPinRed, HIGH);
digitalWrite(ledPinBlue, LOW);
}else if(command == "Blue"){
digitalWrite(ledPinBlue, HIGH);
digitalWrite(ledPinRed, LOW);
}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!
You must login before you can post a comment. .