top of page

Challenge 8

  • Writer: Elvin Shoolbraid
    Elvin Shoolbraid
  • May 23, 2022
  • 3 min read

Updated: May 27, 2022

Description:

For this challenge, we had the choice of either designing a Neopixel/light bar light show, or designing a wearable/e-textiles project. We decided to combine them by designing and building a pair of LED programmable sunglasses. Essentially, two Neopixel rings, one in each lens, and some method of controlling the pattern/effect of the LEDs.


A Screenshot of Code:

/*
 * Neopixel Sunglasses code
 * Created May 16 2022
 * This code runs selection of animated patterns on a neopixel,
 * which can be cycled through with one button, and parametrically
 * randomized with another button.
 */
 
#include <WS2812FX.h> //Library for the neopixel, including animations

#define LED_COUNT 16 //number of LEDs in the neopixel
#define LED_PIN A5 //output pin for neopixel animations

const int modeButtonPin = 10; //pin for the mode button
const int paramsButtonPin = 7; //pin for the parameter button

WS2812FX ringLED = WS2812FX(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800); //declaring the neopixel

bool awaitingModeRelease = false;
bool awaitingParamsRelease = false;

int fxModes[] = {0, 43, 44, 45, 50, 8, 9, 11, 20, 22, 32, 33, 36, 38, 46}; //a curated list of the best 
                                                                           //built in animations
int fxModesAmount = sizeof(fxModes) / 2; //recording the size of the list of animations

int currentMode = 0;
int currentSpeed = 200;         //declare the variable for animation speed, and init to 200 (ms)
uint32_t currentColor = RED;   //declare the animation color variable, for animations that have 1 color

void setup() {
  Serial.begin(9600);

  pinMode(modeButtonPin, INPUT);  //set the button pins to input
  pinMode(paramsButtonPin, INPUT);

                          //power to buttons:
  pinMode(9, OUTPUT);
  pinMode(12, OUTPUT);

  digitalWrite(9, HIGH);
  digitalWrite(12, HIGH);

                       //parameter initialization for neopixel
  ringLED.init();
  ringLED.setBrightness(100);
  ringLED.setSegment(0, 0, LED_COUNT - 1, fxModes[currentMode], currentColor, currentSpeed);
  ringLED.start();

}

void loop() {
                                                                //if the modebutton is pressed, increment the current mode, 
                                                                //looping to 0 if it reaches the end of the list
  if (digitalRead(modeButtonPin) && !awaitingModeRelease) {
    
    currentMode++;
    if (currentMode > (fxModesAmount + 1)) currentMode = 0;
    ringLED.setMode(fxModes[currentMode]);

    Serial.print("Current FX mode: ");
    Serial.println(fxModes[currentMode]);
    
    awaitingModeRelease = true;
  }
                                                                //if the parambutton is pressed,
                                                                //randomize the parameters of the animation
  if (digitalRead(paramsButtonPin) && !awaitingParamsRelease) {

    currentColor = ringLED.color_wheel(ringLED.random8());
    currentSpeed = random(10, 25);

    ringLED.setSegment(0, 0, LED_COUNT - 1, fxModes[currentMode], currentColor, currentSpeed);

    Serial.print("Current speed: ");
    Serial.println(currentSpeed);
    
    awaitingParamsRelease = true;
  }

  awaitingModeRelease = digitalRead(modeButtonPin);
  awaitingParamsRelease = digitalRead(paramsButtonPin);

  ringLED.service();
  delay(10);
}

Photos of the circuit:




A Video of the Circuit Working:



Reflection:

What was the easiest aspect of this challenge?

I think the easiest part of this challenge was identifying what we wanted to do for it. It’s a pretty open ended question, but in a few minutes we realized that a neopixel enabled pair of sunglasses would be just enough of a challenge, and would also give us an opportunity to practice designing more of an end-user experience focused product, rather than a tech demo. This turned out to be challenging.


What was the hardest aspect of this challenge?

The hardest part of this challenge was by far debugging. Throughout the whole construction and testing process, there were countless issues and things that simply didn’t work, with no explanation. The vast majority of time was spent debugging simple systems and trying to get reliable results. This was probably a good taste of designing products in the real world. Another reason I think we had so many technical issues was our goal; an elegant end product that could feasibly be used outside of a tech demo. Optimizing for ease of use and size made things more difficult. We encountered many problems with simply how to connect wires together; The pin system all the components are built around is great for quick prototyping, but the connections fall apart under a little bit of pressure and the bulky nature isn’t great for a wearable design. Much of our trouble would have been solved if I knew how to solder. I’m going to do that next.


What did you learn in the process?

In terms of how not to do things, everything in the previous paragraph. I learned that durable circuits are a must in situations where parts are under stress, and that the simplicity of a system doesn’t necessarily determine its ability to break down without any explanation.


 
 
 

Recent Posts

See All

تعليقات


bottom of page