배송 |
---|
상품 정보 | 가격 | 삭제 |
---|---|---|
아두이노 RTC 실시간 클럭 모듈 / DS1307 RTC I2C Module | ||
TOTAL PRICE(수량) 0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #include <Wire.h> // I2C통신 라이브러리 #include "RTClib.h" // RTC 기본 라이브러리 RTC_DS1307 RTC; // RTC 클래스 생성 void setup () { Serial.begin(9600); Wire.begin(); RTC.begin(); RTC.adjust(DateTime(__DATE__, __TIME__)); // 연결된 PC의 현재 시간을 RTC모듈 기억소자에 동기화 } void loop () { DateTime now = RTC.now(); // 시간을 읽어옴 Serial.print(now.year(), DEC); // 시리얼모니터에 출력 Serial.print('/'); Serial.print(now.month(), DEC); Serial.print('/'); Serial.print(now.day(), DEC); Serial.print(' '); Serial.print(now.hour(), DEC); Serial.print(':'); Serial.print(now.minute(), DEC); Serial.print(':'); Serial.print(now.second(), DEC); Serial.println(); delay(1000); } | cs |