Created
December 16, 2015 00:32
-
-
Save FluffyPira/6f4606ba4e0de9bfcd5c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Adafruit_NeoPixel.h> | |
#define PIN 0 | |
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(32, PIN); | |
// Change These Variables | |
int maxBrightness = 70; | |
int minBrightness = 0; | |
int fadeSpeed = 25; | |
uint8_t mode = 0, // Current animation effect | |
offset = 0; // Position of spinny eyes | |
uint32_t color = 0xff0000; // Start red | |
uint32_t prevTime; | |
void setup() { | |
pixels.begin(); | |
prevTime = millis(); | |
} | |
void loop() { | |
uint8_t i; | |
uint32_t t; | |
switch(mode) { | |
case 0: | |
//Set the color with Red, Gree, Blue values | |
pulseColor(pixels.Color(58, 9, 115), fadeSpeed); | |
pixels.show(); | |
delay(75); | |
break; | |
case 1: // Random sparks - just one LED on at a time! | |
pixels.setBrightness(30); // 1/3 brightness | |
i = random(32); | |
pixels.setPixelColor(i, 0xffffff); | |
pixels.setPixelColor(31-i, 0xcc0000); | |
pixels.show(); | |
delay(25); | |
pixels.setPixelColor(i, 0); | |
pixels.setPixelColor(31-i, 0); | |
break; | |
} | |
t = millis(); | |
if((t - prevTime) > 10000) { // Every 8 seconds... | |
mode++; // Next mode | |
if(mode > 1) { // End of modes? | |
mode = 0; // Start modes over | |
} | |
for(i=0; i<32; i++) pixels.setPixelColor(i, 0); | |
prevTime = t; | |
} | |
} | |
void pulseColor(uint32_t c, uint8_t wait) { | |
//Increase Brightness / Fade In | |
for(int i=minBrightness; i<maxBrightness; i++) { | |
pixels.setBrightness(i); | |
for(int x=0; x<pixels.numPixels(); x++){ | |
pixels.setPixelColor(x,c); | |
} | |
pixels.show(); | |
delay(wait); | |
} | |
//Lower Brightness / Fade Out | |
for(int i=maxBrightness; i>minBrightness; i--) { | |
pixels.setBrightness(i); | |
for(int x=0; x<pixels.numPixels(); x++){ | |
pixels.setPixelColor(x,c); | |
} | |
pixels.show(); | |
delay(wait); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment