Hallo Forum,
Mein Name ist Timo und ich bin dabei mit WS2811 LEDS ein LED Schild zu bauen, brauche das für meinen 18. Geburtstag in 3 Wochen.
So weit so gut, ich habe das Schild fertig, und es läuft auch mit dem Fast LED Chlorpalette Sketch.
Allerdings ist dieser Sketch nicht so genau das was ich mir für das Schild vorstelle.
Ich möchte, dass das Schild für ca 3 Minuten in nur einer Farbe leuchtet, und dann ein Effekt aus dem Sketch Colorpalettes, kommt, danach wieder 3 Minuten eine Farbe, danach wieder ein Effekt.
Mit welchem Ansatz arbeite ich da am besten? Kenne mich nicht besonders aus mit programmieren, und brauche dieses Schild wie gesagt nur für die Party in 3 Wochen.
Es wäre super, wenn mir da jemand helfen könnte. Ich poste hier unten einfach mal den Sketch von Fast LED, und hoffe das mir jemand sagen kann an welcher Stelle ich darin anfangen muss.
Vielen Dank schonmal,
Timo
Ich vermute ich muss meine Änderungen bei void Change Palette Periodically einfügen, da dieses void ja steuert welcher Effekt gerade drankommt. Allerdings weiß ich nicht, wie ich es hinbekomme, dass jeder zweite Effekt einfach nur eine Farbe für 3 Minuten ist. Außerdem verstehe ich nicht mit welcher 'Zeiteinheit' Change Palette Periodically arbeitet. Ist es möglich, dass so zu ändern, dass das Programm nach dem Prinzip arbeitet 'Von Minute 0 bis 1 myRedWhiteBluePalette_p, Von Minute 1 bis 4 alle Leds in einer Farbe, Von Minute 4 bis 5 ...' und so weiter. Es wäre super, wenn mir dabei jemand helfen könnte.
#include <FastLED.h>
#define LED_PIN 10
#define NUM_LEDS 28
#define BRIGHTNESS 64
#define LED_TYPE WS2811
#define COLOR_ORDER RGB
CRGB leds[NUM_LEDS];
#define UPDATES_PER_SECOND 100
CRGBPalette16 currentPalette;
TBlendType currentBlending;
extern CRGBPalette16 myRedWhiteBluePalette;
extern const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM;
void setup() {
delay( 3000 ); // power-up safety delay
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness( BRIGHTNESS );
currentPalette = RainbowColors_p;
currentBlending = BLEND;
}
void loop()
{
ChangePalettePeriodically();
static uint8_t startIndex = 0;
startIndex = startIndex + 1; /* motion speed */
FillLEDsFromPaletteColors( startIndex);
FastLED.show();
FastLED.delay(1000 / UPDATES_PER_SECOND);
}
void FillLEDsFromPaletteColors( uint8_t colorIndex)
{
uint8_t brightness = 255;
for( int i = 0; i < NUM_LEDS; i++) {
leds[i] = ColorFromPalette( currentPalette, colorIndex, brightness, currentBlending);
colorIndex += 3;
}
}
void ChangePalettePeriodically()
{
uint8_t secondHand = (millis() / 1000) % 60;
static uint8_t lastSecond = 99;
if( lastSecond != secondHand) {
lastSecond = secondHand;
if( secondHand == 0) { currentPalette = RainbowColors_p; currentBlending = BLEND; }
if( secondHand == 10) { currentPalette = RainbowStripeColors_p; currentBlending = NOBLEND; }
if( secondHand == 15) { currentPalette = RainbowStripeColors_p; currentBlending = BLEND; }
if( secondHand == 20) { SetupPurpleAndGreenPalette(); currentBlending = BLEND; }
if( secondHand == 25) { SetupTotallyRandomPalette(); currentBlending = BLEND; }
if( secondHand == 30) { SetupBlackAndWhiteStripedPalette(); currentBlending = NOBLEND; }
if( secondHand == 35) { SetupBlackAndWhiteStripedPalette(); currentBlending = BLEND; }
if( secondHand == 40) { currentPalette = CloudColors_p; currentBlending = BLEND; }
if( secondHand == 45) { currentPalette = PartyColors_p; currentBlending = BLEND; }
if( secondHand == 50) { currentPalette = myRedWhiteBluePalette_p; currentBlending = NOBLEND; }
if( secondHand == 55) { currentPalette = myRedWhiteBluePalette_p; currentBlending = BLEND; }
}
}
// This function fills the palette with totally random colors.
void SetupTotallyRandomPalette()
{
for( int i = 0; i < 16; i++) {
currentPalette[i] = CHSV( random8(), 255, random8());
}
}
// This function sets up a palette of black and white stripes,
// using code. Since the palette is effectively an array of
// sixteen CRGB colors, the various fill_* functions can be used
// to set them up.
void SetupBlackAndWhiteStripedPalette()
{
// 'black out' all 16 palette entries...
fill_solid( currentPalette, 16, CRGB::Black);
// and set every fourth one to white.
currentPalette[0] = CRGB::White;
currentPalette[4] = CRGB::White;
currentPalette[8] = CRGB::White;
currentPalette[12] = CRGB::White;
}
// This function sets up a palette of purple and green stripes.
void SetupPurpleAndGreenPalette()
{
CRGB purple = CHSV( HUE_PURPLE, 255, 255);
CRGB green = CHSV( HUE_GREEN, 255, 255);
CRGB black = CRGB::Black;
currentPalette = CRGBPalette16(
green, green, black, black,
purple, purple, black, black,
green, green, black, black,
purple, purple, black, black );
}
// This example shows how to set up a static color palette
// which is stored in PROGMEM (flash), which is almost always more
// plentiful than RAM. A static PROGMEM palette like this
// takes up 64 bytes of flash.
const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM =
{
CRGB::Red,
CRGB::Gray, // 'white' is too bright compared to red and blue
CRGB::Blue,
CRGB::Black,
CRGB::Red,
CRGB::Gray,
CRGB::Blue,
CRGB::Black,
CRGB::Red,
CRGB::Red,
CRGB::Gray,
CRGB::Gray,
CRGB::Blue,
CRGB::Blue,
CRGB::Black,
CRGB::Black
};
Moderator edit:
</mark> <mark>[code]</mark> <mark>
</mark> <mark>[/code]</mark> <mark>
tags added.