#include <Adafruit_NeoPixel.h>
#define PIXEL_PIN D2
#define PIXEL_COUNT 22
#define PIXEL_TYPE NEO_GRB + NEO_KHZ800
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
#include <Arduino_LPS22HB.h>
void setup() {
Serial.begin(9600);
while (!Serial);
if (!BARO.begin()) {
Serial.println("Failed to initialize pressure sensor!");
while (1);
}
strip.begin();
strip.show(); // Initialize all pixels to 'off'
}
void loop() {
Serial.println("START LOOP");
// read the sensor value
float pressure = BARO.readPressure();
float temperature = BARO.readTemperature();
// print the sensor value
Serial.print("Temperature1 = ");
Serial.print(temperature);
Serial.println(" C");
// wait 1 second to print again
delay(10000);
float prev_temp = temperature;
pressure = BARO.readPressure();
temperature = BARO.readTemperature();
Serial.print("Temperature2 = ");
Serial.print(temperature);
Serial.println(" C");
float difference = prev_temp - temperature;
Serial.print("difference = ");
Serial.print(difference);
Serial.println(" C");
Serial.println("END LOOP");
if (difference < 0.05) {
for(int i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, 0, 255, 0 );
strip.show();
delay(100);
}
}
else if (0.05 <= difference && difference < 0.10) {
for(int i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, 255, 255, 0 );
strip.show();
delay(300);
}
}
else if (difference >= 0.10) {
for(int i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, 255, 0, 0 );
strip.show();
delay(500);
}
}
}
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. .