Back to Parent

// This #include statement was automatically added by the Particle IDE.
#include <neopixel.h>

#include "neopixel.h"
#define PIXEL_PIN D3
#define PIXEL_COUNT 62
#define PIXEL_TYPE WS2812
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);

bool warm = true;

void getData()
{
        // Publish an event to trigger the webhook
  Particle.publish( "get-forecast" );

}

void setup() {

    strip.begin();
    strip.show();
    Particle.subscribe("hook-response/get-forecast", handleForecastReceived );
    getData();

}

int light_strip(String command)
{
    if (warm){
        warmer_fade();
        return 1;
    }
  else return -1;
}

//Webhook functions



// This function will handle data received back from the webhook
void handleForecastReceived(const char *event, const char *data) {
  // Handle the integration response

  String receivedStr =  String( data );
  int loc1 = 0;

  loc1 = receivedStr.indexOf("~");

  String temperature_str = receivedStr.substring(0,loc1);
  double temperature = (double) String(temperature_str).toFloat();
  double humidity = (double) String(receivedStr.substring(loc1+1)).toFloat();
  Particle.publish(receivedStr);

}


void cooler_fade(){

    for( int i = 0; i < strip.numPixels(); i++ ){
      strip.setPixelColor(i, 0, 100, 100); // set a color
      strip.show();
      delay( 100 );
     }
     for (int j = 0; j < 3; j++){
         for( int k = 0; k <256; k++ ){
            for( int i = 0; i < strip.numPixels(); i++ ){
                strip.setPixelColor(i, 0, k/3, k/2); // set a color
            }
            strip.show();
            delay( 10 );
        }   

    for( int k = 255; k >=0; k-- ){
        for( int i = 0; i < strip.numPixels(); i++ ){
            strip.setPixelColor(i, 0, k/3, k/2 ); // set a color
        }
            strip.show();
            delay( 10 );
            }
    }



    for( int i = 0; i < strip.numPixels(); i++ ){
        if (i>0){
             strip.setPixelColor(i-1, 0, 0, 0); // set a color
        }
      strip.setPixelColor(i, 0, 100, 100); // set a color
      strip.show();
      delay( 100 );
     }



}

void warmer_fade(){
    for( int i = 0; i < strip.numPixels(); i++ ){
      strip.setPixelColor(i, 235, 52, 100); // set a color
      strip.show();
      delay( 100 );
     }

     for (int j = 0; j < 3; j++){
         for( int k = 0; k <256; k++ ){
            for( int i = 0; i < strip.numPixels(); i++ ){
                strip.setPixelColor(i, k/2, 0, k/3); // set a color
            }
            strip.show();
            delay( 10 );
        }   

    for( int k = 255; k >=0; k-- ){
        for( int i = 0; i < strip.numPixels(); i++ ){
            strip.setPixelColor(i, k/2, 0, k/3); // set a color
        }
            strip.show();
            delay( 10 );
            }
    }



    for( int i = 0; i < strip.numPixels(); i++ ){
        if (i>0){
             strip.setPixelColor(i-1, 0, 0, 0); // set a color
        }
     strip.setPixelColor(i, 235, 52, 155); // set a color
      strip.show();
      delay( 100 );
     }

}

void loop() {

//   uint16_t blue = 0;
//   uint16_t red = 0;
//   uint16_t green = 0;

 // This makes it go brighter and then dim back down
    // warmer_fade();
    cooler_fade();


}
Click to Expand

Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0