- 网页设计
- 整站网页设计
- 网站模板设计
- 网站开发
- 综合门户网开发
- 企业网站开发
- 电子商务网站开发
- 资讯网站开发
- 团购网站开发
- 手机网站开发
- 宣传展示网站
- 网站功能开发
- 网站特效制作
- 应用软件开发
- 手机应用软件
- 计算机应用软件
- 软件美工
- 程序修改
- 仿网站开发
- 脚本插件
- 软件测试
- 网站改版
- 企业办公系统
- 软件汉化
- 软件界面皮肤
- 企业办公系统界面
- 应用移植
- Android开发
- IOS开发
- 应用汉化
- 安卓系统定制
- 网店装修
PCF8583 I2C Real Time Clock RTCMEGA 2560 Arduino实时时钟
PCF8583 I2C Real Time Clock RTC Shield
For R3 MEGA 1280 (咨询特价)
# PCF8583 based RTC with CR2032 battery backup
# Default PCF8583 RTC SCL connected to AN5, SDA connected to AN4
PCF8583 Demo
#include <Wire.h> // necessary, or the application won't build properly
#include <stdio.h>
#include <PCF8583.h>
/*****************************************************************************
* read/write serial interface to PCF8583 RTC via I2C interface
*
* Arduino analog input 5 - I2C SCL (PCF8583 pin 6)
* Arduino analog input 4 - I2C SDA (PCF8583 pin 5)
*
* You can set the type by sending it YYMMddhhmmss;
* the semicolon on the end tells it you're done...
*
******************************************************************************/
int correct_address = 0;
PCF8583 p (0xA0);
void setup(void){
Serial.begin(9600);
Serial.print("booting...");
Serial.println(" done");
}
void loop(void){
if(Serial.available() > 0){
p.year= (byte) ((Serial.read() - 48) *10 + (Serial.read() - 48)) + 2000;
p.month = (byte) ((Serial.read() - 48) *10 + (Serial.read() - 48));
p.day = (byte) ((Serial.read() - 48) *10 + (Serial.read() - 48));
p.hour = (byte) ((Serial.read() - 48) *10 + (Serial.read() - 48));
p.minute = (byte) ((Serial.read() - 48) *10 + (Serial.read() - 48));
p.second = (byte) ((Serial.read() - 48) * 10 + (Serial.read() - 48)); // Use of (byte) type casting and ascii math to achieve result.
if(Serial.read() == ';'){
Serial.println("setting date");
p.set_time();
}
}
p.get_time();
char time[50];
sprintf(time, "%02d/%02d/%02d %02d:%02d:%02d",
p.year, p.month, p.day, p.hour, p.minute, p.second);
Serial.println(time);
delay(3000);
}


浙公网安备 33011002014637号