Powering WB2812 Strips That Are Sound Responsive

I'm In the trial & error/planning phase of making a lamp that is music responive.
MATERIALS:
Arduino Nano
WB2812 LED Strips: 2 Strips of 10 to 12 LED's
3 Pin Sound Sensor
Power: That's My Question????

I'm using a code I found on the internet...Intially I was testing this out with a SINGLE STRIP OF 18 LED'S using the USB Computer Cord as the power supply. I quickly realized that 18 LED's with a sound sensor draws more mA's than the USB can supply or the Nano can handle!!! I found that I could power only 5 LED's with the USB using the program below.

I'll wire in a 330 Ohlm Resistor between the Nano and the DIN of the Strips... My Question is about the power side:
Question 1: Assuming LED's max about 60mA's I think i need a 5V 2amp power supply tor 2 strips of 12 LED's??
Quesiton 2: Can I power the 2 strips from the Nano 5V/Ground with a capacitor 100uF or should I power the strips directly from the external supply and branch off of external to supply the Nano? I think it would be okay to power through the nano with only 20-24 LED's total but I'm not sure how the sound sensor and program flucuate the power needed?
Question 3: I've done some lamps with simple color patterns that useing 2 LED strips that are controlled from individual Digital Pins from the Nano...If I'm having both strips do the same thing can I use 1 digital pin and split the wire at the LED"s to go to both DIN's.

Sorry don't have a mock up to post...too many questions about the wiring and power. I think my biggest concern is getting the power supply right and how to get the power to the LED's.

Code For Lamp:

#include <FastLED.h>

int r=0;
int g=255;
int b=0;

#define LED_PIN     5            //CONNECT DATA PIN OF PIXEL WITH 5 NUMBER PIN OF ARDUINO
#define NUM_LEDS    12        //CHANGE THE VALUE IF YOU WANT TO USE DIFFRENT NUMBER OF LED IN YOUR STRIP,HERE IN MY STRIP NUMBER OF LED IS 60 SO I SET IT 60.

CRGB leds[NUM_LEDS];
CRGB led[NUM_LEDS];
int s=0;

void setup() {

  FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
  for (int i = NUM_LEDS/2; i >= 0; i--) 
  {
     leds[i] = CRGB ( r,g,b);
     leds[NUM_LEDS-i] = CRGB (r,g,b );
     delay(40);
    FastLED.show();
  }
  Serial.begin(9600);
   pinMode(A0,INPUT);

}
void loop()
{
  s=analogRead(A0);
  s=s*2;
 // Serial.println(s);
 // delay(50);
  if((s>=450)&&(s<=550))
  {
    leds[(NUM_LEDS/2)-1]=CRGB (0, 0, 255);
    leds[NUM_LEDS/2]=CRGB (0, 0, 255);
  }
  else if((s>=400)&&(s<=450))
  {
    leds[(NUM_LEDS/2)-1]=CRGB (153, 153, 0);
    leds[NUM_LEDS/2]=CRGB (153, 153, 0);
  }
  else if((s>=350)&&(s<=400))
   {
     leds[(NUM_LEDS/2)-1]=CRGB (255, 50, 255);
    leds[NUM_LEDS/2]=CRGB (255, 50, 255);
   }
   else if((s>=300)&&(s<=350))
  {
    leds[(NUM_LEDS/2)-1]=CRGB (10, 25, 217);
    leds[NUM_LEDS/2]=CRGB (10, 25, 217);
  }

    else if((s>=276)&&(s<=300))
   {
     leds[(NUM_LEDS/2)-1]=CRGB (50, 50, 150);
    leds[NUM_LEDS/2]=CRGB (50, 50, 150);
   }
   else if((s>=250)&&(s<=275))
   {
     leds[(NUM_LEDS/2)-1]=CRGB (230, 0, 10);
    leds[NUM_LEDS/2]=CRGB (230, 0, 10);
   }
  else if((s>=235)&&(s<=250))
   {
     leds[(NUM_LEDS/2)-1]=CRGB (0, 160, 0);
    leds[NUM_LEDS/2]=CRGB (0, 160, 0);
   }
   else if((s>=200)&&(s<=230))
   {
     leds[(NUM_LEDS/2)-1]=CRGB (1, 0, 1);
    leds[NUM_LEDS/2]=CRGB (1, 0, 1);
   }
  else
  {
     leds[(NUM_LEDS/2)-1] = CRGB ( r,s-100,b);
     leds[NUM_LEDS/2] = CRGB ( r,s-100,b);
  }
    for (int i = 0; i <= ((NUM_LEDS/2)-2); i++) 
  {
     leds[i] = leds[i+1];
     leds[NUM_LEDS-1-i] = leds[(NUM_LEDS)-i-2];
     
  }
 FastLED.show();
 delay(25);

}

If I want to control 2 strips I've used the following lines:

 FastLED.addLeds<WS2812B, 4>(leds, NUM_LEDS_PER_STRIP);
  FastLED.addLeds<WS2812B, 6>(leds, NUM_LEDS_PER_STRIP);
  FastLED.setBrightness(50);

Can I paste that into the setup of the main code instead of #define LED_PIN 5?
Also would using the FastLED.setBrightness in the setup reduce the overall power need? I would assume so but I'm not sure if there's something in the rest of the code that would override the brightness setting.

Thanks in advance for any help
Sam

Here's a very rough sketch...


Sam

24 x 0.06 = 1.44A so 2A is plenty for the strips.

NO, NO, NO. The weak onboard regulator will not support that much current. It will get hot and, hopefully, go into shutdown before it dies.

YES, that is the best way, even if it were a few pixels. The Arduino 5V regulator is not a power supply. It is not heat sinked so is pretty weak.

you have the same array for all the leds. They will not operate independently.

If you want 2 separate strips that you control independently you should set up 2 LED arrays and 2 addLeds() functions to assign pins and led arrays and 2 different control pins to which to connect the strips.

#define LED_PINA     4  // connect ledA strip to pin 5
#define LED_PINB     6  // connect ledB strip to pin 6
CRGB ledA[NUM_LEDS];  // array for first  independent strip
CRGB ledB[NUM_LEDS];  //  array for second independent strip

in setup()

FastLED.addLeds<WS2812, LED_PINA, GRB>(ledA, NUM_LEDS);  
FastLED.addLeds<WS2812, LED_PINB, GRB>(ledA, NUM_LEDS);

Then to write to the first strip you write to the ledA array and to the second strip to ledB array.

demo code

#include <FastLED.h>

int r=0;
int g=255;
int b=0;

#define LED_PINA     5            //CONNECT DATA PIN OF PIXEL WITH 5 NUMBER PIN OF ARDUINO
#define LED_PINB     6 
#define NUM_LEDS    12        //CHANGE THE VALUE IF YOU WANT TO USE DIFFRENT NUMBER OF LED IN YOUR STRIP,HERE IN MY STRIP NUMBER OF LED IS 60 SO I SET IT 60.

CRGB ledA[NUM_LEDS];
CRGB ledB[NUM_LEDS];
int s=0;

void setup() {

  FastLED.addLeds<WS2812, LED_PINA, GRB>(ledA, NUM_LEDS);
  FastLED.addLeds<WS2812, LED_PINB, GRB>(ledB, NUM_LEDS);
  for (int i = NUM_LEDS/2; i >= 0; i--) 
  {
     ledA[i] = CRGB ( r,g,b);
     ledB[NUM_LEDS-i] = CRGB (r,g,b );
     delay(400);
    FastLED.show();
  }
  Serial.begin(9600);
   pinMode(A0,INPUT);

}
void loop()
{
}

So more like this...

Would this work if I wanted both strips to operate identically in sync with one another?

Thanks a lot for you help
Sam

The schematic looks good. I usually put a 100uF to 1000uF cap across each strip +5 and ground to help steady the supply during switching, but I don't think that they are required.

I have not done it that way, but yes, I believe so.

Thanks for the help,
Have a good weekend
Sam

1 Like

Especially if there is a significantly long power wire between the supply and the strip. I think 1000uF is way overkill. I use 100uF at the strip terminals.

I thought all was good last night but then today...
I mocked this up using a DC power supply set at 5 volts and 2 amps and nothing happened. The Sound Sensor acts like it's getting power, the Nano lights up, although some of the jumper wires must not seat well in the breadboard because sometimes the pwr light on the nano flickers? I also noticed that the light below the pwr (labeled l) on the Nano flickers/is dull??? I tried a different set up with the same result. The cap is a 270uF.

It seems like if I plug in the Nano to the USB/Computer the pwr light is brighter than when I wire to my external supply? I think it's a wiring breadboard problem. I even re-soldered the wires at the LED strip to make sure the connection was solid there. I think the Nano is ok...I can run the blink progam on it and if I lower the NUM_LEDS down to 5 the program will run fine (connected to the USB)

I'm tempted to hard wire this up to see if it's a connection issue but wanted to make sure I'm not missing anything. I'm new to this and probably think know just enough to be dangerous :slight_smile:


Again thanks for the time and help you put into my questions
Sam

image
In the top photo, the cap does not seem to be connected to anything.

In the bottom photo, the 5V to the strip seems unconnected. Though the photos are a bit hard to follow. Wires leave the picture, wire colors are inconsistent and the Nano pin numbers are not visible.

I kind of thinks so as well.
When I wire I use red wires for Vcc (5V), black wires for ground and the color of the other wires are the resistor color code of the Nano pin to which they are connected. For instance pin 5 would get a green wire and pin 6 a blue wire. For a pin like A0, I use a black wire (0) but put a dab of white out correction fluid on the DuPont connectors. Using a consistent and standard system will greatly mitigate wiring mistakes. I developed this system over 50 years of solderless bread boarding.

Here is a schematic showing how I would wire the circuit.

Please post your latest code.

I tested the above setup with an Uno in place of the Nano and this code. It works as expected. I get a flash of light from the LED strip if I clap my hands or speak loudly by the sound sensor. This is just for testing.

#include <FastLED.h>

const byte DATA_PIN = 5;
const byte SOUND_PIN = A0;

#define LED_TYPE    WS2812
#define COLOR_ORDER GRB
#define NUM_LEDS    12

CRGB leds[NUM_LEDS];

#define BRIGHTNESS          100
#define FRAMES_PER_SECOND  120

void setup()
{
   Serial.begin(115200);
   FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);
   FastLED.setBrightness(BRIGHTNESS);
}

void loop()
{
   int reading = analogRead(SOUND_PIN);
   Serial.println(reading);
   if ( reading > 700)
   {
      for (int n = 0; n < NUM_LEDS; n++)
      {
         leds[n].setHSV( 10, 125, 125);
      }
   }
   if (reading <= 700)
   {
      for (int n = 0; n < NUM_LEDS; n++)
      {
         leds[n].setHSV( 0, 0, 0); //CRGB::Black;
      }
   }
   FastLED.show();
}

It's the same code from the earlier post in this discussion.

I'm going to be really ticked if that's the cause...and maybe schedule an eye exam...


*Rough drawing but I'm assuming that is how I'd bring the power to the sensor and arduino...
*It looks like you're connecting both grounds on the arduino...Is that necessary? The Nano's I have have the 2 ground pins but on opposite sides of the board.
*I know the WB2812 has an arrow that shows the flow of the DIN signal...I'm assuming from your drawing that power and ground can flow from either end.

I like that idea.

Thanks,
Sam

The 2 grounds are tied together on the board. Electrically the same. Don't need to be externally connected. I should fix that.

Yes, power and ground from either end or both ends.

Great...Thanks.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.