Im trying to use some basic code to get some LED's working, however, I'm not having any luck.
The issue I'm having is the LED's will only light up when I bridge all three pads on the strip with my finger (found out by accident); and then will only blink random colours.
#include <FastLED.h>
#define LED_PIN 3
#define NUM_LEDS 120
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<WS2812, LED_PIN, RGB>(leds, NUM_LEDS);
FastLED.setMaxPowerInVoltsAndMilliamps(5, 500);
FastLED.clear();
FastLED.show();
}
void loop() {
// Turn lights from green to blue from left to right R G B
for (int i=0; i<NUM_LEDS; i++){
leds[i] = CRGB(0, 255 - 4*i, 4*i );
FastLED.setBrightness(2*i);
FastLED.show();
delay(50);
}
// Turn lights from blue to magenta from right to left
for (int i=NUM_LEDS; i>0; i--){
leds[i] = CRGB(4*i,0 , 255-4*i);
FastLED.setBrightness(100-i);
FastLED.show();
delay(50);
}
}
Ok, so put a resistor in the data line, ~0.5K, the exact value is not critical, and an electrolytic capacitor across the power connections to the strip, e.g. 1000uF (check polarity!). Ideally both these components should be near the start of the strip, especially if long wires are used.