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