คำสั่ง RTC.adjust(DateTime(__DATE__, __TIME__)); เป็นคำสั่งที่ดึงเวลาจากเครื่องมาใช้ครับ ในรอบถัดไปให้ปิดการใช้งานด้วยไม่งั้นมันมันจะเพี้ยน
Code ผมตามด้านล่างครับ ที่มีปัณหาเรื่อง Library ตอน comply
ผมจะหา Library ให้เหมาะกับ code ได้ยังไงครับ
Library RTC_DS3231.cpp และ RTClib.h RTClib.cpp อยู่ในโฟล์เดอร์นี้ครับ
C:\Users\amornsak\Documents\Arduino\libraries\RTClib\src
#include <Wire.h>
#include <SPI.h>
#include <RTClib.h>
RTC_DS3231 RTC;
void setup () {
Serial.begin(57600);
Wire.begin();
RTC.begin();
RTC.adjust(DateTime(__DATE__, __TIME__));
if(!RTC.isrunning()) {
Serial.println("RTC is NOT running!");
RTC.adjust(DateTime(__DATE__, __TIME__));
}
}
void loop () {
DateTime now = RTC.now();
Serial.print(now.day(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.year(), DEC);
Serial.print(' ');
Serial.print(now.hour());
Serial.print(':');
Serial.print(now.minute());
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
delay(3000);
}
เกี่ยวกับ Library ของ ตัว RTC ครับ DS3231 ใช้ให้ตรงกับ code ครับ
Arduino: 1.8.9 (Windows 10), Board: "Arduino Uno"
C:\Users\amornsak\AppData\Local\Temp\Test\Test.ino: In function 'void setup()':
Test:15:9: error: 'class RTC_DS3231' has no member named 'isrunning'
if(!RTC.isrunning()) {
^~~~~~~~~
exit status 1
'class RTC_DS3231' has no member named 'isrunning'
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.