kk logo

Diese Uhr zeigt euch die Umgerechnete Zeit auf einem NEOpixel Ring an. Diese Seite dient nur als Ergänzung zu diesem Video https://youtu.be/mh1WkDiZuNk und stellt den Code zum kopieren und einfügen bereit. 

neopixel uhr arduino ardublock code

Code im Globalen Bereich:

#include <ThreeWire.h>

#include <RtcDS1302.h>

ThreeWire myWire(6,5,4); // DAT (I/O), CLK (SCLK), RST (CE)

RtcDS1302<ThreeWire> rtc(myWire);

Code im Set up:

Serial.begin(9600); Serial.print("compiled: "); Serial.print(__DATE__); Serial.print(" "); Serial.println(__TIME__); rtc.Begin(); RtcDateTime compiled = RtcDateTime(__DATE__, __TIME__); printDateTime(compiled); Serial.println(); if (!rtc.IsDateTimeValid()) { Serial.println("RTC lost confidence in the DateTime!"); rtc.SetDateTime(compiled); } if (rtc.GetIsWriteProtected()){ Serial.println("RTC was write protected, enabling writing now"); rtc.SetIsWriteProtected(false); } if (!rtc.GetIsRunning()){ Serial.println("RTC was not actively running, starting now"); rtc.SetIsRunning(true); } RtcDateTime now = rtc.GetDateTime(); if (now < compiled) { Serial.println("RTC is older than compile time! (Updating DateTime)"); rtc.SetDateTime(compiled); } else if (now > compiled) { Serial.println("RTC is newer than compile time. (this is expected)"); } else if (now == compiled) { Serial.println("RTC is the same as compile time! (not expected but all is fine)");}

Code im Loop:

RtcDateTime now = rtc.GetDateTime(); printDateTime(now); Serial.println(); if (!now.IsValid()) { Serial.println("RTC lost confidence in the DateTime!"); } delay(100); } #define countof(a) (sizeof(a) / sizeof(a[0]))

//absatz (als Block einfügen nicht als Text!!!)

void printDateTime(const RtcDateTime& dt){ char datestring[25]; char daysOfTheWeek[7][4] = {"Sun","Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; snprintf_P(datestring, countof(datestring), PSTR("%3s, %02u.%02u.%04u %02u:%02u:%02u"), daysOfTheWeek[dt.DayOfWeek()], dt.Day(), dt.Month(), dt.Year(), dt.Hour(), dt.Minute(), dt.Second() ); int sekunden = dt.Second(); int minuten = dt.Minute(); int stunden = dt.Hour();

//absatz (als Block einfügen nicht als Text!!!)

Ronnie

schwäbischer tüftler und bastler, kraftsportler, ADHS power, 43 Jahre, 1 Frau, 5 Kinder und 1003 Ideen. 

ronnie berzins at mee

...

Denn du bist ein Unikat, einzig in deiner Art
Wir alle ecken an so wie in ein Quadrat
Du bist ein Unikat, du bist so wie du bist
Egal, was sie labern, wir geben kein'n Fick.

SDP, Unikat