/************************************************************************************************* PROGRAMMINFO ************************************************************************************************** Funktion: Nuage Clock, Temperatur, Color (Rainbow) ************************************************************************************************** Version: 05.01.2023 ************************************************************************************************** Board: UNO ************************************************************************************************** Libraries: https://github.com/espressif/arduino-esp32/tree/master/libraries C:\Users\User\Documents\Arduino D:\gittemp\Arduino II\A156_Wetterdaten_V3 ************************************************************************************************** C++ Arduino IDE V1.8.19 ************************************************************************************************** Einstellungen: https://dl.espressif.com/dl/package_esp32_index.json http://dan.drown.org/stm32duino/package_STM32duino_index.json http://arduino.esp8266.com/stable/package_esp8266com_index.json **************************************************************************************************/ // Libraries #include "RTClib.h" #include // TM1637 4 digit PINS #define CLK 2 #define DIO 3 // Display Objekt RTC_DS3231 rtc; TM1637Display display = TM1637Display(CLK, DIO); //*********** NEOPIXEL****************************************** #include #ifdef __AVR__ #include #endif #define PIN 7 Adafruit_NeoPixel strip = Adafruit_NeoPixel(20, PIN, NEO_GRB + NEO_KHZ800); //********************************************************************************* // Celsius Symbol: const uint8_t celsius[] = { SEG_A | SEG_B | SEG_F | SEG_G, // Circle SEG_A | SEG_D | SEG_E | SEG_F // C }; void setup() { Serial.begin(115200); // RTC Check if (! rtc.begin()) { Serial.println("RTC-Fehler!"); while (1); } // Überprüfe, ob die RTC Stromversorgung ok ist und stelle die Zeit ein: if (rtc.lostPower()) { Serial.println("RTC Batterie Fehler, stelle die Zeit ein:"); // Die folgende Zeile setzt die RTC auf das Datum und die Uhrzeit: rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); // Diese Zeile setzt die RTC mit einem expliziten Datum & Uhrzeit, z.B. um // Jahr, Monat, Tag, Stunde, Minute, Sekunde //rtc.adjust(DateTime(2023, 1, 05, 15, 57, 0)); } // Display Helligkeit (0-7): display.setBrightness(1); // Lösche Display: display.clear(); //*********** NEOPIXEL****************************************** #if defined (__AVR_ATtiny85__) if (F_CPU == 16000000) clock_prescale_set(clock_div_1); #endif strip.begin(); strip.setBrightness(50); //0-255 strip.show(); //**************************************************************** //*********** NEOPIXEL****************************************** colorWipe(strip.Color( 0, 255, 125) , 0); // R G B Türkis //************************************************************** } void loop() { // Lese Datum und Zeit DateTime now = rtc.now(); // Zeitformat int displaytime = (now.hour() * 100) + now.minute(); Serial.println(displaytime); Serial.print(rtc.getTemperature() - 2); //-2°C Korrektur Serial.println(" °C"); // Anzeige der aktuellen Uhrzeit im 24-Stunden-Format mit aktivierten führenden Nullen und einem Doppelpunkt: display.showNumberDecEx(displaytime, 0b11100000, true); // Entferne die Codezeilen, wenn du einen statischen anstelle eines blinkenden Zwischenpunkts wünscht: // delay(500); // display.showNumberDec(displaytime, true); // Prints displaytime without center colon. delay(3000); display.showNumberDec(rtc.getTemperature() - 2, false, 2, 0); //-2°C Korrektur display.setSegments(celsius, 2, 2); delay(3000); //*********** NEOPIXEL****************************************** /* // Some example procedures showing how to display to the pixels: colorWipe(strip.Color(255, 0, 0), 50); // Red colorWipe(strip.Color(0, 255, 0), 50); // Green colorWipe(strip.Color(0, 0, 255), 50); // Blue //colorWipe(strip.Color(0, 0, 0, 255), 50); // White RGBW // Send a theater pixel chase in... theaterChase(strip.Color(127, 127, 127), 50); // White theaterChase(strip.Color(127, 0, 0), 50); // Red theaterChase(strip.Color(0, 0, 127), 50); // Blue */ // rainbow(50); // rainbowCycle(10); // theaterChaseRainbow(50); //*************************************************************** } //*********** ENDE LOOP ******************************************* //*********** NEOPIXEL****************************************** // Füllee die LEDs nacheinander mit einer Farbe void colorWipe(uint32_t c, uint8_t wait) { for (uint16_t i = 0; i < strip.numPixels(); i++) { strip.setPixelColor(i, c); strip.show(); delay(wait); } } /* void rainbow(uint8_t wait) { uint16_t i, j; for (j = 0; j < 256; j++) { for (i = 0; i < strip.numPixels(); i++) { strip.setPixelColor(i, Wheel((i + j) & 255)); } strip.show(); delay(wait); } } // Slightly different, this makes the rainbow equally distributed throughout void rainbowCycle(uint8_t wait) { uint16_t i, j; for (j = 0; j < 1 * 5; j++) { // 5 cycles of all colors on wheel for (i = 0; i < strip.numPixels(); i++) { strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255)); } strip.show(); delay(wait); } } //Theatre-style crawling lights. void theaterChase(uint32_t c, uint8_t wait) { for (int j = 0; j < 10; j++) { //do 10 cycles of chasing for (int q = 0; q < 3; q++) { for (uint16_t i = 0; i < strip.numPixels(); i = i + 3) { strip.setPixelColor(i + q, c); //turn every third pixel on } strip.show(); delay(wait); for (uint16_t i = 0; i < strip.numPixels(); i = i + 3) { strip.setPixelColor(i + q, 0); //turn every third pixel off } } } } //Theatre-style crawling lights with rainbow effect void theaterChaseRainbow(uint8_t wait) { for (int j = 0; j < 256; j++) { // cycle all 256 colors in the wheel for (int q = 0; q < 3; q++) { for (uint16_t i = 0; i < strip.numPixels(); i = i + 3) { strip.setPixelColor(i + q, Wheel( (i + j) % 255)); //turn every third pixel on } strip.show(); delay(wait); for (uint16_t i = 0; i < strip.numPixels(); i = i + 3) { strip.setPixelColor(i + q, 0); //turn every third pixel off } } } } // Input a value 0 to 255 to get a color value. // The colours are a transition r - g - b - back to r. uint32_t Wheel(byte WheelPos) { WheelPos = 255 - WheelPos; if (WheelPos < 85) { return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3); } if (WheelPos < 170) { WheelPos -= 85; return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3); } WheelPos -= 170; return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0); } */