Chan Namgoong
Published © Apache-2.0

VibraGlow

Music doesn’t just play for the ears but also dances before the eyes.

IntermediateShowcase (no instructions)2 hours536
VibraGlow

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
WS2811 12V Addressable RGB LED Strip Light 16.4ft 150 LEDs
×1
SparkFun Sound Detector (with Headers)
SparkFun Sound Detector (with Headers)
×1
12V 5A 60W Power Supply Adapter Universal Regulated Switching Transformer
×1

Software apps and online services

Arduino IDE
Arduino IDE
FastLED Library

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Tape, Electrical
Tape, Electrical
Wire Stripper & Cutter, 32-20 AWG / 0.05-0.5mm² Solid & Stranded Wires
Wire Stripper & Cutter, 32-20 AWG / 0.05-0.5mm² Solid & Stranded Wires

Story

Read more

Schematics

Schematic

Code

Music Reactive LED

C/C++
Copy and paste code inside Arduino IDE. Instructions commented.
#include <FastLED.h>        // https://github.com/FastLED/FastLED
FASTLED_USING_NAMESPACE

#define NUM_LEDS         150 // Total Number of LEDs
#define DATA_PIN          3 // Connect your Addressable LED Strip to this Pin.
#define LED_TYPE     WS2811 // WS2801, WS2811, WS2812B, LPD8806, TM1809, etc...
#define COLOR_ORDER     RGB // Default Color Order
#define ENVELOPE_PIN     A0 // Envelope Pin of the Sparkfun Sound Detector Module

#define BRIGHTNESS      200 // Min: 0, Max: 255
#define SATURATION      150 // Min: 0, Max: 255
#define MIN_VAL          20 // Adjust this between 0 and 75 for sensitivity
#define MAX_VAL         250 // Adjust this between 75 and 750 for sensitivity
#define HUE_INIT         10 // < 255
#define HUE_CHANGE        2 // < 255

/*============= SELECT STYLE =============*/
/*                                        */
/*    0   -->   LinearReactive            */
/*    1   -->   BrightnessReactive        */
/*                                        */                                        
/* */          int STYLE = 1;          /* */
/*                                        */
/*========================================*/

CRGB leds[NUM_LEDS];
byte dynamicHue = HUE_INIT;
int analogVal = 0;
int val = 0;

void setup() { 
  pinMode(ENVELOPE_PIN, INPUT);
  
  FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  FastLED.setBrightness(BRIGHTNESS);

  for(int i = 0; i < NUM_LEDS; i++) {
    leds[i] = CRGB::Black;
  }

  // Update the LED Strip
  FastLED.show(); 
}

void loop() {
  analogVal = analogRead(ENVELOPE_PIN);

  if(analogVal > MAX_VAL)
    analogVal = MAX_VAL;

  if(analogVal < MIN_VAL)
    analogVal = MIN_VAL;

  switch (STYLE) {
    case 1:
      BrightnessReactive();
      break;
    default:
      LinearReactive();
      break;
  }
  
  // Update the LED Strip
  FastLED.show();
}

void LinearReactive() {
  val = map(analogVal, 0, MAX_VAL+1, 0, NUM_LEDS);

  for(int i = 0; i < NUM_LEDS; i++) {
    if (i <= val)
      leds[i] = CHSV(HUE_INIT+(HUE_CHANGE*i), SATURATION, BRIGHTNESS);
    else
      leds[i].nscale8(10);
  }
}

void BrightnessReactive() {
  val = map(analogVal, MIN_VAL, MAX_VAL, 0, BRIGHTNESS);
  
  for(int i = 0; i < NUM_LEDS; i++) {
    leds[i] = CHSV(HUE_INIT+(HUE_CHANGE*i), SATURATION, val);
  }
}

Credits

Chan Namgoong
1 project • 0 followers
Contact

Comments

Please log in or sign up to comment.