资源简介
arduino 小贱钟源码及教程.

代码片段和文件信息
/*
DS3231.cpp: DS3231 Real-Time Clock library
original code by
Eric Ayars
4/1/11
updated to Arduino 1.0
John Hubert
Feb 7 2012
Released into the public domain.
*/
#include
#define CLOCK_ADDRESS 0x68
// Constructor
DS3231::DS3231() {
// nothing to do for this constructor.
}
/*****************************************
Public Functions
*****************************************/
void DS3231::getTime(byte& year byte& month byte& date byte& DoW byte& hour byte& minute byte& second) {
byte tempBuffer;
bool PM;
bool h12;
Wire.beginTransmission(CLOCK_ADDRESS);
Wire.write(uint8_t(0x00));
Wire.endTransmission();
Wire.requestFrom(CLOCK_ADDRESS 7);
second = bcdToDec(Wire.read());
minute = bcdToDec(Wire.read());
tempBuffer = bcdToDec(Wire.read());
h12 = tempBuffer & 0b01000000;
if (h12) {
PM = tempBuffer & 0b00100000;
hour = bcdToDec(tempBuffer & 0b00011111);
} else {
hour = bcdToDec(tempBuffer & 0b00111111);
}
DoW = bcdToDec(Wire.read());
date = bcdToDec(Wire.read());
month = bcdToDec(Wire.read() & 0b01111111);
year = bcdToDec(Wire.read());
}
byte DS3231::getSecond() {
Wire.beginTransmission(CLOCK_ADDRESS);
Wire.write(uint8_t(0x00));
Wire.endTransmission();
Wire.requestFrom(CLOCK_ADDRESS 1);
return bcdToDec(Wire.read());
}
byte DS3231::getMinute() {
Wire.beginTransmission(CLOCK_ADDRESS);
Wire.write(0x01);
Wire.endTransmission();
Wire.requestFrom(CLOCK_ADDRESS 1);
return bcdToDec(Wire.read());
}
byte DS3231::getHour(bool& h12 bool& PM) {
byte temp_buffer;
byte hour;
Wire.beginTransmission(CLOCK_ADDRESS);
Wire.write(0x02);
Wire.endTransmission();
Wire.requestFrom(CLOCK_ADDRESS 1);
temp_buffer = Wire.read();
h12 = temp_buffer & 0b01000000;
if (h12) {
PM = temp_buffer & 0b00100000;
hour = bcdToDec(temp_buffer & 0b00011111);
} else {
hour = bcdToDec(temp_buffer & 0b00111111);
}
return hour;
}
byte DS3231::getDoW() {
Wire.beginTransmission(CLOCK_ADDRESS);
Wire.write(uint8_t(0x03));
Wire.endTransmission();
Wire.requestFrom(CLOCK_ADDRESS 1);
return bcdToDec(Wire.read());
}
byte DS3231::getDate() {
Wire.beginTransmission(CLOCK_ADDRESS);
Wire.write(uint8_t(0x04));
Wire.endTransmission();
Wire.requestFrom(CLOCK_ADDRESS 1);
return bcdToDec(Wire.read());
}
byte DS3231::getMonth(bool& Century) {
byte temp_buffer;
byte hour;
Wire.beginTransmission(CLOCK_ADDRESS);
Wire.write(uint8_t(0x05));
Wire.endTransmission();
Wire.requestFrom(CLOCK_ADDRESS 1);
temp_buffer = Wire.read();
Century = temp_buffer & 0b10000000;
return (bcdToDec(temp_buffer & 0b01111111)) ;
}
byte DS3231::getYear() {
Wire.beginTransmission(CLOCK_ADDRESS);
Wire.write(uint8_t(0x06));
Wire.endTransmission();
Wire.requestFrom(CLOCK_ADDRESS 1);
return bcdToDec(Wire.read());
}
void DS3231::setSecond(byte Second) {
// Sets the seconds
// This function also resets the Oscillator Stop Flag which is set
// whenever power is interrupted.
Wire.beginTransmission(CLOCK_ADDRESS);
Wire.wr
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 16274 2012-02-08 22:56 Plotclock程序及安装说明\libraries\DS3231_TEST\DS3231.cpp
文件 5161 2012-02-08 22:51 Plotclock程序及安装说明\libraries\DS3231_TEST\DS3231.h
文件 4645 2014-11-13 22:49 Plotclock程序及安装说明\libraries\DS3231_TEST\Examples\DS3231_TEST\DS3231_TEST.ino
文件 548 2012-02-07 11:17 Plotclock程序及安装说明\libraries\DS3231_TEST\keywords.txt
文件 243 2012-02-08 23:05 Plotclock程序及安装说明\libraries\DS3231_TEST\Readme.txt
文件 2641 2010-03-06 11:09 Plotclock程序及安装说明\libraries\Time\DateStrings.cpp
文件 392 2009-12-29 17:24 Plotclock程序及安装说明\libraries\Time\Examples\Processing\SyncArduinoClock\readme.txt
文件 2015 2009-12-30 18:02 Plotclock程序及安装说明\libraries\Time\Examples\Processing\SyncArduinoClock\SyncArduinoClock.pde
文件 2115 2010-01-06 09:45 Plotclock程序及安装说明\libraries\Time\Examples\TimeGPS\TimeGPS.pde
文件 3458 2010-03-06 19:20 Plotclock程序及安装说明\libraries\Time\Examples\TimeNTP\TimeNTP.pde
文件 1043 2010-01-05 14:13 Plotclock程序及安装说明\libraries\Time\Examples\TimeRTC\TimeRTC.pde
文件 3180 2010-01-06 10:30 Plotclock程序及安装说明\libraries\Time\Examples\TimeRTCLog\TimeRTCLog.pde
文件 2228 2010-01-06 09:53 Plotclock程序及安装说明\libraries\Time\Examples\TimeRTCSet\TimeRTCSet.pde
文件 2392 2010-01-06 10:55 Plotclock程序及安装说明\libraries\Time\Examples\TimeSerial\TimeSerial.pde
文件 2129 2010-01-06 10:55 Plotclock程序及安装说明\libraries\Time\Examples\TimeSerialDateStrings\TimeSerialDateStrings.pde
文件 805 2010-01-05 12:02 Plotclock程序及安装说明\libraries\Time\keywords.txt
文件 6979 2010-01-11 21:36 Plotclock程序及安装说明\libraries\Time\Readme.txt
文件 7897 2010-11-01 20:32 Plotclock程序及安装说明\libraries\Time\Time.cpp
文件 5602 2011-07-22 17:30 Plotclock程序及安装说明\libraries\Time\Time.h
文件 9323 2017-03-21 23:15 Plotclock程序及安装说明\Plotclock程序\1.plotclock调试摆臂程序\plotclockadj\plotclockadj.ino
文件 11308 2017-03-21 23:15 Plotclock程序及安装说明\Plotclock程序\2.plotclock主程序 - 有时钟模块版\plotclock\plotclock.ino
文件 10636 2016-07-10 18:24 Plotclock程序及安装说明\Plotclock程序\3.plotclock主程序 - 无时钟模块版\plotclock\plotclock.ino
文件 244 2014-11-08 00:48 Plotclock程序及安装说明\Plotclock程序\3.plotclock主程序 - 无时钟模块版\什么是时钟模块?.txt
文件 5409227 2017-07-30 11:31 Plotclock程序及安装说明\小贱钟安装说明201707.docx
文件 832 2014-12-20 21:31 Plotclock程序及安装说明\说明.txt
目录 0 2016-07-15 17:07 Plotclock程序及安装说明\libraries\Time\Examples\Processing\SyncArduinoClock
目录 0 2016-07-15 17:07 Plotclock程序及安装说明\libraries\DS3231_TEST\Examples\DS3231_TEST
目录 0 2016-07-15 17:07 Plotclock程序及安装说明\libraries\Time\Examples\Processing
目录 0 2016-07-15 17:07 Plotclock程序及安装说明\libraries\Time\Examples\TimeGPS
目录 0 2016-07-15 17:07 Plotclock程序及安装说明\libraries\Time\Examples\TimeNTP
............此处省略21个文件信息
相关资源
- Delphi时钟助手源码,定时关机、提醒
- STM32 led 时钟
- 利用DS1302和msp430进行闹钟和万年历的
- 单片机做的6位时分秒数字钟
- 单片机电子时钟 闹钟 日历
- DAS1302蜂鸣 独立按键 闹钟设定 IIC存储
- vhdl与lcd1602实现的多控制电子钟
- 单片机数字时钟包附电路图 源程序
- 软件方法测试RTX时钟
- (MFC) 时钟日期程序
- 基于89c51的数字钟
- 数字电子技术 多功能数字钟
- 用7490设计一个能计时12小时,计分六
- 图形学集成程序dda、中点算法、多边
- 天文钟GPS对时程序
- fpga数字钟
- 数字钟
- 8086电子钟
- 30分钟读懂ITIL4
- flash透明时钟140个
- actel fpga外部输入时钟毛刺问题排查与
- STM32F407实时时钟_DS1302实时时钟模块和
- 基于STM32F103的实时时钟程序,采用D
- 51单片机_DS1302时钟芯片_共阴数码管
- 数字钟计时器的设计与制作
- Qt时钟Demo,在原来基础上添加了秒针
- DS1302时钟带可调时间显示
- Lcd12864大时钟万年历 农历生肖温度
- 基于FFMPEG_SDL2_音视频播放_参考音频时
- 迅雷赚钱宝PRO圆形二代宝救砖刷机教
评论
共有 条评论