Back to Parent

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

// IMPORTANT: Set pixel COUNT, PIN and TYPE
#define PIXEL_COUNT 1
#define PIXEL_PIN D7
#define PIXEL_TYPE WS2812B
Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);

int redValue = 255; // Full brightness for an ANODE RGB LED is 0, and off 255
int greenValue = 255; // Full brightness for an ANODE RGB LED is 0, and off 255
int blueValue = 255; // Full brightness for an ANODE RGB LED is 0, and off 255</td>
int buzzerPin = D5; // output pin for buzzer
int tempPin = A0;

int piezoPin = D2; // Setting up the piezo buzzer pin
int piezoPitch = 500;

double tempC;
String sugg;
void setup() {
    pinMode( tempPin , INPUT); // sets pin as input
    pinMode(piezoPin, OUTPUT);
    Particle.variable("temprature",tempC);
    Particle.variable("Suggestion",sugg);

	
  // Set up our NEOPIXEL RGB Pin pins for output
    strip.begin();
}

void loop() {
    double voltage;
    int readSum = 0;
    int read[10];
    int j;
    //taking a sample of temprature reading over a period of one second
    for(j=0; j<10;j++){
        read [j] = analogRead(tempPin);
        readSum = readSum + read[j];
        delay(100);
    }
    //average out the readings to reduce noise
    int reading = readSum/j;
    voltage = (reading * 3.3) / 4095.0;
    tempC = (voltage - 0.5) * 100;
    if (tempC<=-7){
        sugg = "Its crazy cold today! Try to cover up all exposed body parts!!";
        //pulsating purpule
        for (int i=0; i<5; i++){
                setRGBColor( 175,25,175); //set led to flash Purple
                delay(500);
                setRGBColor( 0,0,0);
                tone(piezoPin, piezoPitch, 100); //warning sound for extreme weather
                delay(500);
            }
            delay(1000); //remove the flickering
        }
    else if (tempC<=5 && tempC>-7){
        sugg = "Its quite cold today! Consider layering up!!";
        setRGBColor( 0,0,255); //Set the LED to flash Blue
        delay(1000); //remove the flickering
    }
    else if(tempC>5 && tempC<=15 ){
        sugg = "Its somewhat cold. Probably you should get a sweater";
        setRGBColor( 0,255,153); //set led to flash green-blue
        delay(1000); //remove the flickering
        
    }
    else if(tempC>15 && tempC<=30){
        sugg = "Its a pleasent day. Have a good one!";
            setRGBColor( 251,234,0); //set led to flash yellow
            delay(1000); //remove the flickering
       
    }
    else if(tempC>30 && tempC<=45){
        sugg = "Its a warm day today! Consider some light clothes!";
        setRGBColor( 2243,73,8); //set led to flash orange
        delay(1000); //remove the flickering
       
    }
    else{
        sugg = "Its quite hot today! Be careful!!";
        //pulsating red
            for (int i=0; i<5; i++){
                setRGBColor( 255,0,0); //set led to flash Purple
                delay(500);
                setRGBColor( 0,0,0);
                tone(piezoPin, piezoPitch, 100);
                delay(500);
             }
            delay(1000); //remove the flickering
        }
    }
void setRGBColor( int r, int g, int b ){
	
  redValue = r;
  greenValue = g;
  blueValue = b;
	
  strip.setPixelColor(0, redValue, greenValue, blueValue);
  strip.show();
}
Click to Expand

Content Rating

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

0