// This #include statement was automatically added by the Particle IDE.
#include <neopixel.h>
// Include Particle Device OS APIs
#include "Particle.h"
#include <neopixel.h>
#define PIXEL_PIN SPI // plug into pin MO
#define PIXEL_COUNT 12 // 0 addressed
//#define PIXEL_TYPE SK6812RGBW
#define PIXEL_TYPE WS2812
// Let Device OS manage the connection to the Particle Cloud
SYSTEM_MODE(AUTOMATIC);
// Show system, cloud connectivity, and application logs over USB
// View logs with CLI using 'particle serial monitor --follow'
SerialLogHandler logHandler(LOG_LEVEL_INFO);
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
static int photoPin = A0;
static int tempPin = A1;
uint32_t w = strip.Color(0, 0, 0, 255); // Pure white
uint32_t blue = strip.Color(0, 0, 255); // Blue
uint32_t green = strip.Color(0, 255, 0); // Green
uint32_t red = strip.Color(255, 0, 0); // Green
uint32_t c1 = green;
uint32_t c2 = w;
int photoReading = 0;
int tempReading = 0;
int tempOut =0;
int photoOut = 0;
// setup() runs once, when the device is first turned on
void setup() {
Particle.variable("Brightness", photoReading);
Particle.variable("Temperature", tempReading);
strip.begin();
}
// loop() runs over and over again, as quickly as it can execute.
void loop() {
photoReading = analogRead(photoPin);
tempReading = analogRead(tempPin);
// tempOut = map(tempReading, 3300, 4000, 1, 2);
// photoReading = map(photoReading, 200, 400, 1, 2);
tempOut = map(tempReading, 0, 100, 1, 2);
photoReading = map(photoReading, 0, 100, 1, 2);
delay(100);
if (photoOut == 2){
// Particle.publish();
kiss();
}
else{
ambient();
}
if(tempOut == 1){
c1 = red;
}
else if(tempOut == 2){
c1 = blue;
}
delay (500);
}
int ambient(){
for( int i = 0; i < strip.numPixels(); i++ ){
strip.setPixelColor(i, c1); // set a color
strip.show();
delay( 100 );
}
return 1;
}
int kiss(){
for( int i = 0; i < strip.numPixels(); i++ ){
strip.setPixelColor(i, c1); // set a color
strip.show();
delay( 100 );
}
for( int i = 0; i < strip.numPixels(); i++ ){
strip.setPixelColor(i, c2); // set a color
strip.show();
delay( 100 );
}
return 1;
}
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. .