Тема 5.2: DateTime (с использованием библиотек RTClib.h)
Установка и использование библиотек RTClib.h Компоненты использования:Arduino Uno// lisame RTClib.h library#include <Wire.h>#include <RTClib.h>RTC_DS1307 rtc;void setup (){Serial.begin(9600);Wire.begin();rtc.begin();//if (! rtc.isrunning()) { Serial.println(“RTC is NOT running!”); // following line sets the RTC to the date & time this sketch was compiled rtc.adjust(DateTime(__DATE__, __TIME__));//}}void loop () {DateTime now = rtc.now();//char dt[10];//char tm[10];//sprintf(__DATE__, “%02d/%02d/%02d”, now.year(),now.month(),now.day());//sprintf(__TIME__, “%02d:%02d:%02d”, now.hour(),now.minute(),now.second());Serial.print(__DATE__);Serial.print(” “);Serial.println(__TIME__);Serial.println();delay(1000);
Copy and paste this URL into your WordPress site to embed
Copy and paste this code into your site to embed