#define HIGH 3 #define NORMAL 2 //How long do we keep the "current average" sound, before restarting the measuring in a song ) #define LONG_SECTOR 50 //Mneumonics #define AVGLEN 5 //How many previous sensor values decides if we are on a peak/HIGH (e.g. How many previous sensor values effects the operating average? #define MIC_LOW 0.0 #define MIC_HIGH 737.0 /** Other macros */ #define ANALOG_READ 0 //Confirmed microphone low value, and max value #define LED_PIN 6 //The pin that we read sensor values form #define NUM_LEDS 60 //The pin that controls the LEDs The USB of the Arduino is connected to your computer. GND of the LED strip goes to GND of the extra power supply and to the GND of the Arduino. +5V of the LED strip goes to the +5V of extra power supply. The DIN (data input) pin of the LED strip goes to Arduino PIN 6 with an optional 470Ω resistor in between. Verification with a Voltage meter is recommended.Ĭommonly, during testing, your Arduino is connected to your computer via a USB cable where the USB cable does not only program the microcontroller but will also provide power for the Arduino. You can use an external power supply for this purpose and even though my 1 meter strip theoretically needs 3.6 A at max brightness, my little 2A power supply managed to handle it – your milage may vary! (1 meter with 60 LEDs/meter = 60 * 60 mA = 3600 mA = 3.6 A max.)Ī switching power supply is often ideal and pretty cheap – you might even have one or the other laying around from your old cellphone, just make sure it’s actually giving you 5 – 6V and not weird voltages like 12V or 16V or even more. LED’s, even though they’re called power efficient, do need juice … and for each WS2812 we need up to 60 mA when the 3 LEDs inside are at maximum brightness at 5V. Rule of thumb is : each RGB LED unit pulls about 60 mA (3x 20 mA, for Red, Green and Blue). Now that we have a WS2812 strip, time to hook it up to our Arduino (I used an Arduino UNO for this).Ī strip of LED’s will pull way too much power for your Arduino to handle, so always consider an additional 5V power supply. Strips can be had in waterproof (in plastic “tube”) or for indoor use only.ĭigital LED strip – WS2812 (top) and WS2801 (bottom).There are digital strips that look like WS2801/WS2811/WS2812 strip, that are NOT based on any of these LED drivers.WS2801 has 4 pins, where as the WS2811/WS2812 only has 3 pins.Notice the arrows indicating Data direction.strips can be sold as a white or a black strip (background strip).Not all strips of the same “model”, look the same, but have typically a very similar layout.In the illustration below you can see the physical differences between the WS2801 and the WS2811/WS2812 strips.Unlike the analog strips: Most Digital RGB strips operate on 5 Volts! Obviously the kind we’d like to use in our projects. The cool part of a digital strip is that you address each LED individually, making very cool effects easy. In particular: we will use the WS2812 in our project. The digital strips are the ones we will use in this project. Actually, note that out minimum is now not fully off (it is 1 not 0) and our maximum is out of range ( 256 not 255).Analog LED strips – Single color (top), Multicolor (bottom) In our case, given that we are dealing with computers that like binary, powers of two are convenient. You can generate this result by treating your intensity as a power to raise some number to. What you need to do instead is set your intensity exponentially. So by taking the minimum duty cycle (say 0) and maximum duty cycle (say, for the sake of easy math this is 10) and dividing it into equal chunks, you will be controlling the intensitiy linearly which will not give satisfying results. The analogWrite() routines are setting the output pin's PWM duty cycle, and are linear. What the other answers omit about this topic is the fact that that human perception of light intensity is logarithmic, not linear.
0 Comments
Leave a Reply. |