Created
January 22, 2016 15:34
-
-
Save LindseyB/a4a879a52e68ab8a646d to your computer and use it in GitHub Desktop.
This file contains 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> | |
#ifdef __AVR_ATtiny85__ // Trinket, Gemma, etc. | |
#include <avr/power.h> | |
#endif | |
#define PIN 1 | |
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(32, PIN); | |
uint8_t offset = 0; | |
// red, orange, yellow, green, blue, indigo, violet, pink | |
uint32_t colors[8] = {0xFF0000, 0xFF6600, 0xFFFF00, 0x00FF00, 0x0000FF, 0x4B0082, 0xEE82EE, 0xFFCCCC}; | |
uint32_t prevTime; | |
void setup() { | |
#ifdef __AVR_ATtiny85__ // Trinket, Gemma, etc. | |
if(F_CPU == 16000000) clock_prescale_set(clock_div_1); | |
#endif | |
pixels.begin(); | |
pixels.setBrightness(85); // 1/3 brightness | |
prevTime = millis(); | |
} | |
void loop() { | |
uint8_t i; | |
uint32_t t; | |
for(i=0; i<16; i++) { | |
uint32_t c = colors[(i+offset)%8]; | |
pixels.setPixelColor( i, c); // First eye | |
pixels.setPixelColor(31-i, c); // Second eye (flipped) | |
} | |
pixels.show(); | |
offset++; | |
delay(50); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment