久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

專注電子技術學習與研究
當前位置:單片機教程網 >> Arduino >> 瀏覽文章

Arduino驅動DS3231高精度時鐘模塊

作者:huqin   來源:本站原創   點擊數:  更新時間:2014年04月03日   【字體:

很想要個時鐘模塊,自己焊又太麻煩,干脆在TB上買下來了,省時。

  模塊參數:
  1.尺寸:38mm(長)*22mm(寬)*14mm(高)
  2.重量:8g
  3.工作電壓:3.3--5.5V
  4.時鐘芯片:高精度時鐘芯片DS3231
  5.時鐘精度:0-40℃范圍內,精度2ppm,年誤差約1分鐘
  6.帶2個日歷鬧鐘
  7.可編程方波輸出
  8.實時時鐘產生秒、分、時、星期、日期、月和年計時,并提供有效期到2100年的閏年補償
  9.芯片內部自帶溫度傳感器,精度為±3℃
  10.存儲芯片:AT24C32(存儲容量32K)
  11.IIC總線接口,最高傳輸速度400KHz(工作電壓為5V時)
  12.可級聯其它IIC設備,24C32地址可通過短路A0/A1/A2修改,默認地址為0x57
  13.帶可充電電池LIR2032,保證系統斷電后,時鐘任然正常走動

 

接線說明,以Arduino uno r3為例:
  SCL→A5
  SDA→A4
  VCC→5V
  GND→GND

 
 

代碼部分:

#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秒)循環一次。
}

關閉窗口

相關文章

主站蜘蛛池模板: 亚洲精品在线免费 | 国产在线精品一区二区三区 | 中文字幕乱码一区二区三区 | 在线观看中文字幕dvd播放 | 午夜精品视频在线观看 | 99热视| 亚洲精品久久 | 在线观看中文字幕dvd播放 | 一区二区三区成人 | 成人免费大片黄在线播放 | 欧美一区2区三区4区公司 | 中文字幕在线看第二 | 久久久久中文字幕 | 午夜久久久久久久久久一区二区 | 国产激情综合五月久久 | 一级黄色夫妻生活 | 亚洲高清视频一区二区 | 亚洲视频在线观看 | 国产精品免费在线 | 天天操天天射综合 | 95国产精品 | 久久精品视频亚洲 | 伊人网站视频 | 精品福利在线 | 9久久精品| 亚洲精品美女视频 | 国产精品乱码一二三区的特点 | 伊人网在线播放 | 欧美激情久久久 | 国产精品国色综合久久 | 国产精品久久国产愉拍 | 久草在线高清 | 蜜桃臀av一区二区三区 | 天天影视网天天综合色在线播放 | 亚洲a视频 | 成人国产精品久久久 | 欧美黄色一区 | 国产成人99久久亚洲综合精品 | 久久久精品一区二区三区 | 国产精彩视频一区 | 中文字幕第十页 |