// This #include statement was automatically added by the Particle IDE.
#include <neopixel.h>
// This #include statement was automatically added by the Particle IDE.
#include <neopixel.h>
#include <math.h>
#include "Particle.h"
#include "neopixel.h"
SYSTEM_MODE(AUTOMATIC);
// IMPORTANT: Set pixel COUNT, PIN and TYPE WS2812B E357163
#define PIXEL_PIN D2
#define PIXEL_COUNT 7
#define PIXEL_TYPE WS2812B
Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
int conditionPin = A1;
int conditionVal = 0;
// Prototypes for local build, ok to leave in for Build IDE
void rainbow(uint8_t wait);
uint32_t Wheel(byte WheelPos);
int pixel_position = 0;
int startTime = -1;
int checkTime1 = 5000 ;
int checkTime2 = 10000 ;
int checkTime3 = 5000 ;
unsigned long currentTime = -1;
void setup()
{
Serial.begin(9600);
Particle.variable( "condition", conditionVal );
strip.begin();
strip.show(); // Initialize all pixels to 'off'
delay(1000);
startTime = startTime + millis();
}
void loop()
{
//rainbow(20);
int x;
conditionVal = analogRead(conditionPin);
Serial.println(conditionVal);
x = map(conditionVal, 0, 4096, 0, 255);
uint32_t c = strip.Color(255-x, 255-x, x);
// three states color change
if (x > 170) { c = strip.Color(0, 0, 255); } // blue
else if (x < 90) { c = strip.Color(255, 255, 0); } // yellow
else { c = strip.Color(255, 255, 255); } // white
for (int i = 0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, c);
}
strip.setBrightness(255);
strip.show();
}
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. .