아두이노

RTC(Real Time Clock) - DS3231

iseohyun 2022. 1. 18.

목차

     

    #include <DS1302.h>
    
    #define SCK_PIN 4
    #define IO_PIN 3
    #define RST_PIN 2
    
    DS1302 rtc(RST_PIN, IO_PIN, SCK_PIN);
    
    void setup()
    {
    	rtc.halt(false);
    	rtc.writeProtect(false);
    
    	Serial.begin(9600);
    /*
    	rtc.setDOW(THURSDAY);
    	rtc.setTime(8, 43, 0);
    	rtc.setDate(2, 9, 2021); /**/
    }
     
    void loop()
    {
    	Serial.print("It is ");
    	Serial.print(rtc.getDOWStr());
    	Serial.print(" / ");
    	Serial.print(rtc.getDateStr());
    	Serial.print(" / ");
    	Serial.println(rtc.getTimeStr());
    
    	/* Wait before reading again */
    	delay (1000);
    }

    '아두이노' 카테고리의 다른 글

    7-Segment  (0) 2022.01.18
    스텝모터(28BYJ-48)  (0) 2022.01.18
    인체감지센서  (0) 2022.01.18
    키패드  (0) 2022.01.18
    초음파센서  (0) 2022.01.18

    댓글