Bill Jefferson MaclangJohn Arvin Nuarin
Published © GPL3+

Weather Status Light with Gmail Notification and Artik Cloud

Let you know the intensity of weather in your town or city by means of status light displayed on the LED.

BeginnerFull instructions provided1 hour858
Weather Status Light with Gmail Notification and Artik Cloud

Things used in this project

Hardware components

LED (generic)
LED (generic)
×4
Pushbutton switch 12mm
SparkFun Pushbutton switch 12mm
×1
Resistor 10k ohm
Resistor 10k ohm
×1
Breadboard (generic)
Breadboard (generic)
×1
Gizduino
×1
Wire Cable - By the Foot
OpenBuilds Wire Cable - By the Foot
×1

Software apps and online services

OpenWeatherMap API
keycdn.com
Arduino IDE
Arduino IDE
Python IDLE
ARTIK Cloud for IoT
Samsung ARTIK Cloud for IoT
Google Mail
SmartThings service
IFTTT SmartThings service

Story

Read more

Custom parts and enclosures

weather.png

Schematics

weather.png

Code

weather_status

C/C++
Code of arduino where led manipulation happens
const int buttonPin = 6; 
int flag = 1;         // on/off state
int buttonState;             // the current reading from the input pin
int lastButtonState = LOW;   // the previous reading from the input pin

// the following variables are long's because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long lastDebounceTime = 0;  // the last time the output pin was toggled
long debounceDelay = 50;    // the debounce time; increase if the output flickers
int start;
char inByte;
void setup() {
  Serial.begin(9600);
  for (int x = 2; x <= 5; x++){
    pinMode(x, OUTPUT);
  }
  Serial.write('s');
}
void loop() {
  //Specifies if data from python is available
  if(Serial.available()){
    inByte = Serial.read();
     if(start == 0){
       digitalWrite(inByte,HIGH);
       start = 1;
     }
  }
            
  // read the state of the switch into a local variable:
  int reading = digitalRead(buttonPin);

  // check to see if you just pressed the button 
  // (i.e. the input went from LOW to HIGH),  and you've waited 
  // long enough since the last press to ignore any noise:  

  // If the switch changed, due to noise or pressing:
  if (reading != lastButtonState) {
    // reset the debouncing timer
    lastDebounceTime = millis();
  } 
  
  if ((millis() - lastDebounceTime) > debounceDelay) {
    // whatever the reading is at, it's been there for longer
    // than the debounce delay, so take it as the actual current state:

    // if the button state has changed:
  if (reading != buttonState) {
    buttonState = reading;

    // only toggle the LED if the new button state is HIGH
    if (buttonState == HIGH) {
      //negates the current value
      flag = !flag;
        //Pauses the execution of Weather Disturbance Status Light
        if (flag == 0){
          closeAll();
          delay(1000);
          Serial.write('p');
        }
        //Starts the execution of Weather Disturbance Status Light
        else{
          closeAll();
          digitalWrite(inByte,HIGH);
          delay(1000);
          Serial.write('s');
        }
      }
    }
  }
  lastButtonState = reading;
}
  


//closes all LED lights
void closeAll(){
  for (int x = 2; x <= 5; x++){
    digitalWrite(x, LOW);
  }
}

Credits

Bill Jefferson Maclang

Bill Jefferson Maclang

1 project • 2 followers
John Arvin Nuarin

John Arvin Nuarin

1 project • 1 follower
Network Engineer, Web and Android Apps Developer.

Comments