Skip to content

Instantly share code, notes, and snippets.

@chardane
Created February 19, 2018 22:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chardane/77580edd180e5f8a78f88c645a1030a4 to your computer and use it in GitHub Desktop.
Save chardane/77580edd180e5f8a78f88c645a1030a4 to your computer and use it in GitHub Desktop.
#include "neopixel/neopixel.h"
#define PIXEL_COUNT 30
#define PIXEL_PIN D5
#define PIXEL_TYPE WS2812
#define PEACH 200,50,5
#define WHITE 150,150,150
#define CYAN 10,150,70
#define PURPLE 180,3,180
#define BLUE 5,5,190
#define GREEN 10,180,10
int waitTime = 25;
bool lampState = false;
void off();
int lampy(String arg);
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
void setup() {
strip.begin();
strip.show();
Particle.function("lamp", lampy);
}
void loop() {
if (lampState == true) {
rainbow_up(PEACH);
rainbow_up(CYAN);
rainbow_up(PURPLE);
rainbow_up(GREEN);
rainbow_up(BLUE);
} else {
off();
}
}
void rainbow_up(int R, int G, int B) {
for(int i=0; i < PIXEL_COUNT; i++) {
strip.setPixelColor(i, R,G,B);
strip.show();
delay(waitTime);
}
}
void off() {
for(int i=0; i < PIXEL_COUNT; i++) {
strip.setPixelColor(i, 0,0,0);
}
strip.show();
delay(waitTime);
}
int lampy(String arg){
//toggle
if(arg == "true") {
lampState = true;
} else {
lampState = false;
}
return 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment