February 1, 2026
Description
Da die Länge eines kommerziellen Hundehalsbandes mit LED Beleuchtung zu lang war haben wir dieses gekürzt...
Um den flexiblen (Fieberglas-?)Stab war es zu schade...
Daher habe ich ein einfaches Gehäuse gebaut und am Boden zwei WS2812 / WS2812B Farb-LEDs angeklebt. Diese steuere ich mit einem ESP8266 (D4-PIN) an, der ebenfalls in der Kiste Platz findet...
Im Ergebnis wir zufällig eine Farbe gewählt und langsam auf der einen LED "gefadet". Wenige Sekunden später zieht die LED nach. Nach 10 Sekunden startet der ganze Prozess von vorne...
Entspannt und ganz niedlich - wer es mag...
:-)
Achtung, das USB Kabel sollte VOR dem löten in die Kiste eingefädelt werden...
Visual Studio Code:
c++-Programm:
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:nodemcuv2]
platform = espressif8266
board = nodemcuv2
framework = arduino
lib_deps =
fastled/FastLED @ ^3.6.0
build_flags =
-Wno-unused-variable
#include <FastLED.h>
#define LED_PIN 2 // D4 am ESP8266 ist GPIO2
#define NUM_LEDS 2
#define BRIGHTNESS 150 // 0 bis 255
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];
CRGB targetColor;
CRGB sourceColors[NUM_LEDS];
// Zeitsteuerung
unsigned long lastCycleStart = 0;
const unsigned long cycleInterval = 10000; // 10 Sekunden Gesamtzyklus
const unsigned long fadeDuration = 3000; // 3 Sekunden Fading-Zeit
void setup() {
// Kurze Sicherheitsverzögerung
delay(1000);
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(BRIGHTNESS);
// Startfarbe schwarz
fill_solid(leds, NUM_LEDS, CRGB::Black);
FastLED.show();
// Initialen Timer setzen
lastCycleStart = millis();
targetColor = CHSV(random8(), 255, 255); // Erste Zufallsfarbe
}
void loop() {
unsigned long currentMillis = millis();
unsigned long elapsed = currentMillis - lastCycleStart;
// --- PHASE 1: LED 0 fadet ---
if (elapsed <= fadeDuration) {
fract8 amount = map(elapsed, 0, fadeDuration, 0, 255);
leds[0] = blend(sourceColors[0], targetColor, amount);
}
// --- PHASE 2: LED 1 fadet (startet wenn LED 0 fertig ist) ---
else if (elapsed <= (fadeDuration * 2)) {
leds[0] = targetColor; // Sicherstellen, dass LED 0 final ist
unsigned long fadeStartLED2 = fadeDuration;
fract8 amount = map(elapsed, fadeStartLED2, fadeDuration * 2, 0, 255);
leds[1] = blend(sourceColors[1], targetColor, amount);
}
// --- PHASE 3: Warten bis 10 Sek um sind ---
else if (elapsed >= cycleInterval) {
// Zyklus Reset: Neue Zufallsfarbe wählen
lastCycleStart = currentMillis;
sourceColors[0] = leds[0];
sourceColors[1] = leds[1];
targetColor = CHSV(random8(), 255, 255); // Wählt zufälligen Farbton (HSV)
}
FastLED.show();
}
08.06.2026:
Bin nicht sicher ob beide Teile im STL waren - jetzt noch einmal komplett...
License:
Creative Commons - Attribution - Non-Commercial - Share Alike
1,342