欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 3177|回復: 1
收起左側

Arduino驅動DS3231高精度時鐘模塊

[復制鏈接]
ID:344144 發表于 2018-6-3 18:45 | 顯示全部樓層 |閱讀模式
#include <DS3231.h>
#include <Wire.h>
DS3231 Clock;
bool Century=false;
bool h12;
bool PM;
byte ADay, AHour, AMinute, ASecond, ABits;
bool ADy, A12h, Apm;
byte year, month, date, DoW, hour, minute, second;
void setup() {
// 啟動I2C(IIC)接口
Wire.begin();
        //以下部分是初始化時間,每次板子通電之后都會初始化成這個時間,只是測試用,以后可以刪除。
        Clock.setSecond(50);//Set the second
        Clock.setMinute(59);//Set the minute 設置分鐘
        Clock.setHour(11);  //Set the hour 設置小時
        Clock.setDoW(5);    //Set the day of the week 設置星期幾
        Clock.setDate(31);  //Set the date of the month 設置月份
        Clock.setMonth(5);  //Set the month of the year 設置一年中的月份
        Clock.setYear(13);  //Set the year (Last two digits of the year) 設置年份(在今年的最后兩位數——比如2013年最后的13)
// Start the serial interface
Serial.begin(115200);
}
void ReadDS3231()
{
  int second,minute,hour,date,month,year,temperature;
  second=Clock.getSecond();
  minute=Clock.getMinute();
  hour=Clock.getHour(h12, PM);
  date=Clock.getDate();
  month=Clock.getMonth(Century);
  year=Clock.getYear();
  
  temperature=Clock.getTemperature();
  
  Serial.print("20");
  Serial.print(year,DEC);
  Serial.print('-');
  Serial.print(month,DEC);
  Serial.print('-');
  Serial.print(date,DEC);
  Serial.print(' ');
  Serial.print(hour,DEC);
  Serial.print(':');
  Serial.print(minute,DEC);
  Serial.print(':');
  Serial.print(second,DEC);
  Serial.print('\n');
  Serial.print("Temperature=");  //這里是顯示溫度
  Serial.print(temperature);
  Serial.print('\n');
}
void loop()
{
  ReadDS3231();
  delay(1000);  //間隔1000ms(1000ms=1秒)循環一次。
}




回復

使用道具 舉報

ID:234938 發表于 2020-1-14 22:32 | 顯示全部樓層
感謝樓主分享!請問這個DS3231是否可以直接獲取電腦時間?
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表