#include <Adafruit_NeoPixel.h>
#include <Wire.h>
#include "RTClib.h"
// RTC-Instanz
RTC_DS1307 rtc;
// Pin- und LED-Konfiguration
#define PIN_H5 5
#define NUM_H5 4
#define PIN_H1 6
#define NUM_H1 4
#define PIN_M5 3
#define NUM_M5 11
#define PIN_M1 4
#define NUM_M1 4
// NeoPixel-Objekte
Adafruit_NeoPixel stripH5(NUM_H5, PIN_H5, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel stripH1(NUM_H1, PIN_H1, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel stripM5(NUM_M5, PIN_M5, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel stripM1(NUM_M1, PIN_M1, NEO_GRB + NEO_KHZ800);
void setup() {
Serial.begin(9600);
Wire.begin();
rtc.begin();
stripH5.begin(); stripH5.setBrightness(127); stripH5.show();
stripH1.begin(); stripH1.setBrightness(127); stripH1.show();
stripM5.begin(); stripM5.setBrightness(127); stripM5.show();
stripM1.begin(); stripM1.setBrightness(127); stripM1.show();
}
void loop() {
// 1) Zeit auslesen
DateTime now = rtc.now();
byte hours = now.hour(); // 0–23
byte minutes = now.minute(); // 0–59
// 1a) Zeit per Serial ausgeben
Serial.print("Aktuelle Zeit: ");
if (hours < 10) Serial.print('0');
Serial.print(hours);
Serial.print(':');
if (minutes < 10) Serial.print('0');
Serial.println(minutes);
// 2) Blöcke berechnen
byte h5 = hours / 5;
byte h1 = hours % 5;
byte m5 = minutes / 5;
byte m1 = minutes % 5;
// 3) LEDs setzen (umgekehrte Reihenfolge)
// Zeile H5 (4 LEDs, rot)
for (byte i = 0; i < NUM_H5; i++) {
byte idx = NUM_H5 - 1 - i;
if (i < h5) {
stripH5.setPixelColor(idx, stripH5.Color(255,0,0));
} else {
stripH5.setPixelColor(idx, 0);
}
}
stripH5.show();
// Zeile H1 (4 LEDs, rot)
for (byte i = 0; i < NUM_H1; i++) {
byte idx = NUM_H1 - 1 - i;
if (i < h1) {
stripH1.setPixelColor(idx, stripH1.Color(255,0,0));
} else {
stripH1.setPixelColor(idx, 0);
}
}
stripH1.show();
// Zeile M5 (11 LEDs, gelb; 3.,6.,9. rot)
for (byte j = 0; j < NUM_M5; j++) {
byte idx = NUM_M5 - 1 - j;
if (j < m5) {
if (j == 2 || j == 5 || j == 8) {
stripM5.setPixelColor(idx, stripM5.Color(255,0,0));
} else {
stripM5.setPixelColor(idx, stripM5.Color(255,255,0));
}
} else {
stripM5.setPixelColor(idx, 0);
}
}
stripM5.show();
// Zeile M1 (4 LEDs, gelb)
for (byte i = 0; i < NUM_M1; i++) {
byte idx = NUM_M1 - 1 - i;
if (i < m1) {
stripM1.setPixelColor(idx, stripM1.Color(255,255,0));
} else {
stripM1.setPixelColor(idx, 0);
}
}
stripM1.show();
delay(20000);
}