Migrate to Arduino: NeoPixel 7-phase relaxation (10/8/5/2/1/4/7 Hz)

This commit is contained in:
Clawdia
2026-09-09 17:17:28 +02:00
parent 907de6fd25
commit 3d7417e837
7 changed files with 91 additions and 517 deletions
+86
View File
@@ -0,0 +1,86 @@
/*
* led_entspannung.ino
* LED-Entspannungsablauf für XIAO ESP32-C6 + 30x WS2812B
*
* Pin: D10 (GPIO18) wie im "Standard-Code" getestet und bestätigt
* Ablauf (auto-Start beim Einschalten):
* 1) Ankommen / Beta→Alpha 10 Hz 60 s (255, 80, 0)
* 2) Alpha-Entspannung 8 Hz 90 s (255, 40, 0)
* 3) Theta-Eintauchen 5 Hz 90 s (200, 0, 0)
* 4) Delta-Regeneration 2 Hz 120 s (180, 0, 0)
* 5) Delta-Tiefschlaf 1 Hz 120 s (150, 0, 0)
* 6) Theta-Aufstieg 4 Hz 90 s (220, 30, 0)
* 7) Alpha-Weckphase 7 Hz 90 s (255, 60, 0)
* Danach: alle LEDs aus, 3 s Pause, dann von vorn.
*
* Arduino-IDE:
* - Board: "Seeed XIAO ESP32C6"
* - Port: COMx (bzw. /dev/ttyACM0)
* - Bibliothek "Adafruit NeoPixel" muss installiert sein
* - Upload → fertig, es startet automatisch
*/
#include <Adafruit_NeoPixel.h>
#define LED_PIN 18 // D10
#define NUM_LEDS 30
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, LED_PIN, NEO_GRB + NEO_KHZ800);
struct Phase {
uint8_t r, g, b;
uint32_t freq_hz;
uint32_t duration_s;
const char *name;
};
static const Phase phases[] = {
{ 255, 80, 0, 10, 60, "Ankommen / Beta-Alpha" },
{ 255, 40, 0, 8, 90, "Alpha-Entspannung" },
{ 200, 0, 0, 5, 90, "Theta-Eintauchen" },
{ 180, 0, 0, 2, 120, "Delta-Regeneration" },
{ 150, 0, 0, 1, 120, "Delta-Tiefschlaf" },
{ 220, 30, 0, 4, 90, "Theta-Aufstieg" },
{ 255, 60, 0, 7, 90, "Alpha-Weckphase" },
};
#define NUM_PHASES (sizeof(phases) / sizeof(phases[0]))
void setup() {
Serial.begin(115200);
delay(500);
Serial.println("==== LED-Entspannungsablauf (7 Phasen) ====");
Serial.printf("XIAO ESP32-C6 | D10 (GPIO%d) | %d LEDs\n", LED_PIN, NUM_LEDS);
strip.begin();
strip.setBrightness(255);
strip.show(); // alles aus
Serial.println("Strip initialisiert, Start in 1 s ...");
delay(1000);
}
void loop() {
for (int p = 0; p < NUM_PHASES; p++) {
const Phase &ph = phases[p];
Serial.printf("Phase %d/%d: %s %d Hz %d s (%d,%d,%d)\n",
p + 1, NUM_PHASES, ph.name, ph.freq_hz, ph.duration_s, ph.r, ph.g, ph.b);
uint32_t start = millis();
while (millis() - start < ph.duration_s * 1000UL) {
uint32_t half_ms = (1000UL / ph.freq_hz) / 2; // 50 % ein / 50 % aus
for (int i = 0; i < NUM_LEDS; i++) strip.setPixelColor(i, ph.r, ph.g, ph.b);
strip.show();
delay(half_ms);
strip.clear();
strip.show();
delay(half_ms);
}
}
// Kurze Pause zwischen Durchläufen
Serial.println("Durchlauf beendet - 3 s Pause, dann neu");
strip.clear();
strip.show();
delay(3000);
}