Friday, December 13, 2019

LED Concert Jacket - Alvin Tran, Annie Xu, and Devansh Gandhi

LED Concert Jacket by Annie Xu, Alvin Tran, and Devansh Gandhi 


Our project is a light jacket that visualizes how excited and engaged you are at a concert. We wanted the jacket to reflect the movement and energy of the wearer, which could signal to the artist or the people around exactly how involved they were during the concert. We hoped the jacket could create competition between friends, immerse experiences for concert goers, and create unspoken relationships between artists and their fans. 


The jacket has 3 tiers each with its own set color. In the beginning, you start on a silvery pink color. For every jump you make, the jacket will turn to that specific color. If you do not move, then the jacket will not light up. In order to reach the next their which blinks yellow, you need to surpass a threshold. If you jump more than a designated amount of time, your jacket will turn yellow every time you jump. In addition, if you scream or make noise, the microphone will pick that up and override the jacket with red lights. The people around you can visually see that you are yelling. When and if you pass the 2nd threshold, your jacket will blink rainbow lights, indicating that you have reached the last tier. At this point, you and the people around you will be able to see your overall activity and engagement during the concert. If one reaches rainbow, that means they were extremely engaged and had many jumps and screams throughout the concert. 

The jacket has an accelerometer that measures acceleration of movement. Therefore, not only does the wearer have to jump, they have to jump fast.  For our project, we set the code so that it only detects movement in the Z direction. The jacket will only respond to jumps or movements up and down. The jacket is programmed so that after a specific number of jumps, the LED will change colors. As for the sound, there is a sound detector that signals the LED to turn red when a certain threshold is reached.

Components
Arduino uno
Rain jacket 
Led strip 
Sound detector LM 393
ADXL335 3-Axis accelerometer 
330 ohm resistor
Electrical tape 
Portable battery 


Libraries:
Fast LED library link: http://fastled.io


 Photos:







CODE:
#include <FastLED.h>
#define LED_PIN     8
#define NUM_LEDS    60


const int xpin = A0; // x-axis of the accelerometer
const int ypin = A1; // y-axis
const int zpin = A2; // z-axis


CRGB leds[NUM_LEDS];


int zTimes = 0;


int soundDetectedPin = 10; // Use Pin 10 as our Input
boolean bAlarm = false;
int soundDetectedVal = HIGH; // This is where we record our Sound Measurement
unsigned long lastSoundDetectTime; // Record the time that we measured a sound
int soundAlarmTime = 100; // Number of milli seconds to keep the sound alarm high


void setup()
{
  Serial.begin(9600);  
  FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
  pinMode(soundDetectedPin, INPUT); // input from the Sound Detection Module
}


void loop() {
  int x = analogRead(xpin); //read from xpin
  Serial.print(x);
  Serial.print("\t");


  
  checkX(x);
  Serial.println(soundDetectedVal);


  soundDetectedVal = digitalRead (soundDetectedPin) ; // read the sound alarm time
  Serial.println(soundDetectedVal);
  Serial.println("checking...");
  if (soundDetectedVal == LOW) // If we hear a sound
  {
    Serial.println("LOW...");
    lastSoundDetectTime = millis(); // record the time of the sound alarm
    // The following is so you don't scroll on the output screen
    if (!bAlarm){
      Serial.println("LOUD, LOUD");
      bAlarm = true;
      for (int i = 0; i <= NUM_LEDS; i++) {
        leds[i] = CRGB::Red;
        FastLED.show();
        delay(10);
      }
    }
  }
  else
  {
    Serial.println("ELSE...");
    if((millis()-lastSoundDetectTime) > soundAlarmTime  && bAlarm){
      Serial.println("quiet");
      bAlarm = false;
      for (int i = 0; i <= NUM_LEDS; i++) {
        leds[i] = CRGB::Black;
        FastLED.show();
        delay(1);
      }
    }
    bAlarm = false;
  }
  
}

void checkX(int x) 
{
if ((x > 300 && x < 400)) {
    for (int i = 0; i <= NUM_LEDS; i++) {
    leds[i] = CRGB::Black;
    FastLED.show();
    delay(1);
    }
    delay(100);
  } else {
    Serial.print("X moving");
    zTimes++;
    Serial.print(zTimes);
    Serial.print("times");
    if(zTimes <= 20){
      for (int i = 0; i <= NUM_LEDS/2; i++) {
        leds[i] = CRGB::Silver;
        leds[NUM_LEDS - i] = CRGB::Silver;
        FastLED.show();
        delay(10);
      }
    } else if (zTimes <= 40) {
      for (int i = 0; i <= NUM_LEDS; i++) {
      leds[i] = CRGB::Yellow;
      FastLED.show();
      delay(10);
      }
    } else {
      for (int i = 0; i <= NUM_LEDS; i++) {
      leds[i] = CRGB(random(0, 255), random(0, 255), random(0, 255));
      FastLED.show();
      delay(10);
      }
    }
    
  }
}








No comments:

Post a Comment