I have been stuggleing with this problem as my current program for useing the XIAO with a WS2812 LED strip works properly when I run it trough Arduino IDE like it's supposed to but when I just plug it into a powersource (that be my laptop or a powerbank) the progam doesn't work properly. It seems to take 3 steps and switch inbetween those instaid of following the full range from dim to bright and back. I have no idea how to fix it as the program works when it's run trough Arduino IDE. I did use the FastLED libaray.
I use the following code:
#include <FastLED.h>
#define LED_PIN D10
#define NUM_LEDS 15
#define LED_TYPE WS2811 //WS2811, WS2812, WS2812B
#define COLOR_ORDER RGB
#define CHANNEL 0
#define BRIGHTNESS 255
#define DATA_PIN D10
int ledPin = D10;
CRGB leds[NUM_LEDS];
void showLed() {
for (int i=0; i<NUM_LEDS; i++ )
{
leds[i] = CRGB(239, 0, 255); //groen rood blauw
uint8_t brightness = (exp(sin(millis() / 3000.0 * PI)) - 0.368) * 42.546;
Serial.println(sin(brightness));
if (brightness<5){
brightness=5;
FastLED.setBrightness(brightness);}
else{
FastLED.setBrightness(brightness);}
FastLED.show();
}
}
void setup() {
FastLED.addLeds<WS2812B, DATA_PIN>(leds, NUM_LEDS);
Serial.begin(9600);
}
void loop() {
showLed();
}
Below is how it is currently set up
Does anyone have a idea on what I need to do to give the LED strip a 'breating' effect when I plug it into a powersource?
Thank you in advance