Nuno and Ryan
Published

Weather light

When the weather is higher than 65 F, the red LED will light up and when the weather is lower than 65 F, the yellow LED will light up.

BeginnerWork in progress403
Weather light

Things used in this project

Story

Read more

Schematics

screen_shot_2017-12-19_at_8_40_02_am_jYeXkAODHD.png

Code

Untitled file

C/C++
int led1 = D2;
int led2 = D1;

void setup() {
 pinMode(led1, OUTPUT);
 pinMode(led2, OUTPUT);
  Particle.function("led",ledToggle);
  digitalWrite(led1, LOW);
  digitalWrite(led2, LOW);
}

void loop() {
}
int ledToggle(String command) {
    if (command == "Hot") {
     digitalWrite(led1, HIGH);
     digitalWrite(led2, LOW);
     return 2;
  } 
  else if (command == "Cold") {
  digitalWrite(led1, LOW);
  digitalWrite(led2, HIGH);
  return 1;
  } 
    else if (command == "Off") {
  digitalWrite(led1, LOW);
  digitalWrite(led2, LOW);
  return 0;
  } 
  else {
      return -1;
  }
}

Credits

Nuno and Ryan

Nuno and Ryan

1 project • 0 followers
Thanks to Mike Soltys.

Comments

Add projectSign up / Login