===== Arduino-WS (6) =====
FastLED-Library
1. http://fastled.io/
Klick auf "Releases" im Menü
herunterscrollen zu "Downloads"
Source code (zip)
Source code (tar.gz)
2. auspacken, ins arduino_sketch-Unter-Verzeichnis "libraries"
3. Verzeichnis umbenennnen in "FastLED"
4. Ggf. Arduino neustarten
C-Kenntnisse - Struct
typedef struct
{ uint8_t r;
uint8_t g;
uint8_t b;
} my_RGB;
my_RGB px;
px.r=255;
my_RGB pxs[3];
pxs[0].r=255;
Das erste Programm mit WS2812b LED-Streifen
#include
const int LEDPin = 4;
const int NPixels = 9;
CRGB leds[NPixels];
int pos=0;
void setup()
{ FastLED.addLeds(leds, NPixels);
}
void loop()
{
for (int i=0; i= NPixels) pos=0;
delay(200);
}
/*
Ungefähr (aus FastLEDpixeltypes.h)
struct CRGB
{ union
{ struct
{ union
{ uint8_t r;
uint8_t red;
};
union
{ uint8_t g;
uint8_t green;
};
union
{ uint8_t b;
uint8_t blue;
};
};
uint8_t raw[3];
};
...
};
struct CRGB
{ uint8_t r;
uint8_t g;
uint8_t b;
};
*/
Experimental..temporär:
#include
const int LEDPin = 4;
const int NPixels = 18;
CRGB leds[NPixels];
typedef struct
{ uint8_t r,g,b;
int pos;
} PUNKT;
const int NPunkte = 6;
PUNKT punkte[NPunkte];
int pos=0;
void setup()
{
FastLED.addLeds(leds, NPixels+2); // +2 zur Sicherheit für Effekte
for (int j=0; j= NPixels-1) pos=0;
delay(200);
}
/*
Ungefähr (aus FastLEDpixeltypes.h)
struct CRGB
{ union
{ struct
{ union
{ uint8_t r;
uint8_t red;
};
union
{ uint8_t g;
uint8_t green;
};
union
{ uint8_t b;
uint8_t blue;
};
};
uint8_t raw[3];
};
...
};
struct CRGB
{ uint8_t r;
uint8_t g;
uint8_t b;
};
a[1] = {60,0,0};
*/
}
{{tag> Frickl}}