0

Glowing Eyes Cosplay using Goggles Kit
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Glowing Eyes Cosplay using Goggles Kit

by divisionten on Fri Nov 10, 2017 10:35 am

I've bought the goggles kit, assembled, tested. Everything works great!

Now I need to actually program the Neopixels on the Trinket and I'm out of my league. I want the pixels to glow solid blue most of the time and every once in a while (say 1-3 minutes, do the spiny effect outlined in the test code, but instead of only having four lights on (two sets of two), I want all but four lights on, in white, spinning.

I will not be seeing out of the eyes- my visibility comes from another part of the costume. :)

Here's the test code, for those unfamiliar:

Code: Select all | TOGGLE FULL SIZE
// Low power NeoPixel goggles example.  Makes a nice blinky display
// with just a few LEDs on at any time.
 
#include <Adafruit_NeoPixel.h>
#ifdef __AVR_ATtiny85__ // Trinket, Gemma, etc.
 #include <avr/power.h>
#endif
 
#define PIN 0
 
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(32, PIN);
 
uint8_t  mode   = 0, // Current animation effect
         offset = 0; // Position of spinny eyes
uint32_t color  = 0xFF0000; // Start red
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;
 
  switch(mode) {
 
   case 0: // Random sparks - just one LED on at a time!
    i = random(32);
    pixels.setPixelColor(i, color);
    pixels.show();
    delay(10);
    pixels.setPixelColor(i, 0);
    break;
 
   case 1: // Spinny wheels (8 LEDs on at a time)
    for(i=0; i<16; i++) {
      uint32_t c = 0;
      if(((offset + i) & 7) < 2) c = color; // 4 pixels on...
      pixels.setPixelColor(   i, c); // First eye
      pixels.setPixelColor(31-i, c); // Second eye (flipped)
    }
    pixels.show();
    offset++;
    delay(50);
    break;
  }
 
  t = millis();
  if((t - prevTime) > 8000) {      // Every 8 seconds...
    mode++;                        // Next mode
    if(mode > 1) {                 // End of modes?
      mode = 0;                    // Start modes over
      color >>= 8;                 // Next color R->G->B
      if(!color) color = 0xFF0000; // Reset to red
    }
    for(i=0; i<32; i++) pixels.setPixelColor(i, 0);
    prevTime = t;
  }
}

divisionten
 
Posts: 3
Joined: Thu Jul 21, 2016 4:10 pm

Please be positive and constructive with your questions and comments.