NeoPixel Goggles

Parts:
2x 16 x 5050 RGBW NeoPixel Rings

1x Steampunk Goggles

1x ESP32 TTGO T-Display

1x 1300mAh Li-Ion Battery


Both NeoPixels are connected to Pin 17 of the ESP32.

The ESP32 has a built-in battery plug that was used to connect the 1200mAh li-ion battery.

Code (Arduino C++):


#include <Adafruit_NeoPixel.h>
#define PIN 17#define BTN 35
Adafruit_NeoPixel strip = Adafruit_NeoPixel(16, PIN, NEO_RGBW + NEO_KHZ800);
void setup() { pinMode(BTN, INPUT); strip.begin(); //initializes NeoPixels strip.show(); //turns off NeoPixels}
void loop() { colorWipe(strip.Color(0, 0, 0, 255), 50); // White colorWipe(strip.Color(255, 0, 0), 50); // Red colorWipe(strip.Color(0, 255, 0), 50); // Green colorWipe(strip.Color(0, 0, 255), 50); // Blue rainbow(20); //runs rainbow function rainbowCycle(20); //runs rainbowCycle function singleDot(strip.Color(0, 0, 0, 255), 50); // White singleDot(strip.Color(255, 0, 0), 50); // Red singleDot(strip.Color(0, 255, 0), 50); // Green singleDot(strip.Color(0, 0, 255), 50); // Blue}
void singleDot(uint32_t c, uint8_t wait) { strip.clear();// resets neopixel strip
for (int i = 0; i < 16; i++) {
strip.setPixelColor(i, c); //turns on pixel number "c" based on the for loop. strip.setPixelColor(i - 2, strip.Color(0, 0, 0)); //turns off the pixel 2 behind the one that was turned on strip.show(); // shows NeoPixels delay(wait); // waits for a few milliseconds }}
void colorWipe(uint32_t c, uint8_t wait) { for (uint16_t i = 0; i < strip.numPixels(); i++) { strip.setPixelColor(i, c); //turns on the next consecutive neopixel after a certain delay. strip.show(); delay(wait); }}
void rainbow(uint8_t wait) { uint16_t i, j;
for (j = 0; j < 256; j++) { for (i = 0; i < strip.numPixels(); i++) { strip.setPixelColor(i, Wheel((i + j) & 255)); //sets all neopixels to a certain color of the rainbow and changes after a certain delay } strip.show(); delay(wait); }}
void rainbowCycle(uint8_t wait) { uint16_t i, j;
for (j = 0; j < 256 * 5; j++) { for (i = 0; i < strip.numPixels(); i++) { strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255)); //sets each neopixel a different color in coordination with a rainbow. } strip.show(); delay(wait); }}
uint32_t Wheel(byte WheelPos) { //the Wheel variable is used in the function `rainbowCycle()` to set each section of the wheel to a certain hue. if (WheelPos < 85) { return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0); } else if (WheelPos < 170) { WheelPos -= 85; return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3); } else { WheelPos -= 170; return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3); }}