有没有人用arduino做过Ds3231时钟模块+IIC 1602显示的时钟?如题。
有没有人用arduino做过Ds3231时钟模块+IIC 1602显示的时钟?如题。 如果做过,那你再做也没意思了,如果没做过,那你就没答案了。{:soso_e143:} 学习一下。 献丑献丑#include <Wire.h>
#include <LiquidCrystal.h>
#include <DS3231.h>
#include "dht.h"
// Arduino的SCL引脚位于模拟端口5,SDA引脚位于模拟端口4。
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
DS3231 Clock;
bool Century=false;
bool PM=false;
dht DHT;
#define DHT11_PIN 6
byte year, month, date, DoW, hour, Minute, Second;
void setup() {
// set up the LCD's number of columns and rows:
Wire.begin();
lcd.begin(16, 2);
// Turn on the blinking cursor:
lcd.blink();
}
void loop()
{
hour=Clock.getHour(Century, PM);
Minute=Clock.getMinute();
Second=Clock.getSecond();
lcd.home();
lcd.setCursor(0, 0);
// 以下是在每天的22:22做的时间修正
// if (hour==22 && Second==22 && Minute== 22){ Clock.setSecond(Second+1-1);}
if (hour<10)lcd.print(" ");
lcd.print(hour);
lcd.print(":");
if (Minute<10)lcd.print(" ");
lcd.print(Minute);
lcd.print(":");
if (Second<10)lcd.print(" ");
lcd.print(Second);
lcd.setCursor(10, 0);
lcd.print(" T=");
lcd.print(Clock.getTemperature(), 1);
lcd.print(" ");
lcd.setCursor(15, 0);
if( Second<30 )
{
lcd.setCursor(0, 1);
lcd.print(Clock.getYear());
lcd.print("-");
lcd.print(Clock.getMonth(Century));
lcd.print("-");
lcd.print(Clock.getDate());
lcd.print(" WeEk :");//显示周几。
lcd.print(Clock.getDoW());
}
else
{
lcd.setCursor(0, 1);
lcd.print("HUMIDY=");//显示湿度。
lcd.print(DHT.humidity, 0);
lcd.setCursor(10, 1);
lcd.print(" T=");
lcd.print( DHT.temperature,1);
}
delay(500);
}
感谢,请问校时是采取的什么方法?有图吗?
楼主大神,请问有木有正常显示的i2c 1602库文件和测试显示程序,我的没显示啊:'( XS★@ 发表于 2014-3-15 20:21
**** 作者被禁止或删除 内容自动屏蔽 ****
没看懂Clock.setSecond(Second+1-1),解释一下
DS3231一年最多差2min,精度挺高的,没必要校正吧
http://www.crystalradio.cn/forum.php?mod=viewthread&tid=830288&orderby=dateline&orderby=dateline
页:
[1]