bubblemanster
Published © GPL3+

Sound-controlled Neopixel LED Lights

Neopixel Lights that are triggered by music/ tone of sound on a sound sensor.

IntermediateShowcase (no instructions)689
Sound-controlled Neopixel LED Lights

Things used in this project

Hardware components

Adafruit NeoPixel Digital RGB LED Strip 144 LED, 1m White
Adafruit NeoPixel Digital RGB LED Strip 144 LED, 1m White
×1
Arduino UNO
Arduino UNO
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Sound Sensor Switch Electronics
×1

Story

Read more

Schematics

Wiring Schematic

Code

Rainbow Reactive Neopixels

Arduino
#include <FastLED.h>
#define NUM_LEDS 60
#define DATA_PIN 6
#define AVG_NOISE_LVL 970
#define MAX_NOISE_LVL 1023

CRGB leds[NUM_LEDS];

int numLedsToLight = 0;

void setup() { 
  FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
  FastLED.clear();
}

void loop() {
  int val = analogRead(A0);
  numLedsToLight = map(val, MAX_NOISE_LVL-AVG_NOISE_LVL, 0, 0, NUM_LEDS);
  int brightness = map(val, MAX_NOISE_LVL-AVG_NOISE_LVL, 0, 0, 255);

  for(int led = numLedsToLight; led >= 0; led--) { 
    rainbow_wave(10, 10);
  }
  delay(10);
  FastLED.setBrightness(brightness);
  FastLED.show();
  // First, clear the existing led values
  FastLED.clear(false);
}

void rainbow_wave(uint8_t thisSpeed, uint8_t deltaHue) {     // The fill_rainbow call doesn't support brightness levels.
 
// uint8_t thisHue = beatsin8(thisSpeed,0,255);                // A simple rainbow wave.
  uint8_t thisHue = beat8(thisSpeed,255);                     // A simple rainbow march.
    
  fill_rainbow(leds, numLedsToLight, thisHue, deltaHue);            // Use FastLED's fill_rainbow routine.
 
}

Credits

bubblemanster
1 project • 1 follower
Contact

Comments

Please log in or sign up to comment.