theres a neopixel example i want to use with fastled but i cant figure out the equivalent code for fastled.
this is all the code they give you, mainly setPixel is giving me trouble.
void loop() {
RunningLights(0xff,0xff,0x00, 50);
}
void RunningLights(byte red, byte green, byte blue, int WaveDelay) {
int Position=0;
for(int j=0; j<NUM_LEDS*2; j++)
{
Position++; // = 0; //Position + Rate;
for(int i=0; i<NUM_LEDS; i++) {
// sine wave, 3 offset waves make a rainbow!
//float level = sin(i+Position) * 127 + 128;
//setPixel(i,level,0,0);
//float level = sin(i+Position) * 127 + 128;
setPixel(i,((sin(i+Position) * 127 + 128)/255)*red,
((sin(i+Position) * 127 + 128)/255)*green,
((sin(i+Position) * 127 + 128)/255)*blue);
}
showStrip();
delay(WaveDelay);
}
}
here a link to the example,
Can someone convert that to fastled for me please
What libraries are you using
.
You forgot to include the headers in your post.
But have you completely read the article you linked to?
It is clearly written how to make those algorithms work both using the FastLED library and using the NeoPixel library
Yea and i said setPixel is giving me trouble. What i mean is, i cant figure out how to convert that part. There was no example how to conver it to fastLed. Atleast tgat i understood.
https://www.tweaking4all.com/hardware/arduino/adruino-led-strip-effects/#FastLEDFramework
#include "FastLED.h"
#define NUM_LEDS 60
CRGB leds[NUM_LEDS];
#define PIN 6
void setup()
{
FastLED.addLeds<WS2811, PIN, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
}
// *** REPLACE FROM HERE ***
void loop() {
// ---> here we call the effect function <---
}
// ---> here we define the effect function <---
// *** REPLACE TO HERE ***
void showStrip() {
// FastLED
FastLED.show();
}
void setPixel(int Pixel, byte red, byte green, byte blue) {
// FastLED
leds[Pixel].r = red;
leds[Pixel].g = green;
leds[Pixel].b = blue;
}
void setAll(byte red, byte green, byte blue) {
for(int i = 0; i < NUM_LEDS; i++ ) {
setPixel(i, red, green, blue);
}
showStrip();
}
thanks. i didn't see that....lol.
Anyways, thats what i was looking for basically
You can also redefine the functions using the CRGB data type instead single green, red and blue bytes.
In this way, you can easily use the predefined color list available with FastLED.
void setPixel(int Pixel, CRGB color) {
// FastLED
leds[Pixel] = color;
}
void setAll(CRGB color) {
for(int i = 0; i < NUM_LEDS; i++ ) {
setPixel(i, color);
}
showStrip();
}
Usage:
setPixel(0, CGRB::DarkViolet);
setPixel(1, CRGB::AliceBlue);
setPixel(2, CRGB::WhiteSmoke);
.....
setAll(CGRB::Black);