FastLED for Better Performance

#include "FastLED.h"

#define NUM_LEDS 20 
#define DATA_PIN 12

CRGB leds[NUM_LEDS];

long currentMillis=0;
long lastMillis = 0;
long loops = 0;

uint8_t hue = 0;
int i = 0;

void setup()
{
Serial.begin(57600);
LEDS.addLeds<WS2812,DATA_PIN,RGB>(leds,NUM_LEDS);
LEDS.setBrightness(64);
}

void loop()
{
showfps();

i=beatsin8(25,0,NUM_LEDS,0,0)
leds[i]=CHSV(hue,255,255);
Fastled.show();
fadeToBlackBy(leds,NUM_LEDS,8);
}

void showfps()
{
currentMillis=millis();
loops++;
if(currentMillis-lastMillis>1000)
{
Serial.println(loops);
lastMillis=currentMillis;
loops=0;
}
}

 

Leave a Reply