LCD和RTC_DS1307-无法正确打印LCD上的1-9位秒数
LCD and RTC_DS1307- Unable to print the 1-9 digit seconds on the lcd correctly
我已将RTC模块和LCD连接到Arduino。时间打印正确,但当它是实时的10:13:09时,在液晶显示器上,它会打印为10:13:19。当时间到了10:13:10时,打印结果很好。示例:上午10:13:58
上午10:13:59
上午10:14:10
10:14:11。。。这是的问题
10:14:19 有问题
上午10:14:10
10:14:11…等
我的代码(不确定哪里出了问题):
//time displayed on lcd
lcd.setCursor(4, 0);
lcd.print(now.hour(), DEC);
lcd.print(':');
lcd.print(now.minute(), DEC);
lcd.print(':');
if(Serial.print(now.second(), DEC) >= 10){
lcd.setCursor(10,0);
lcd.print(now.second(), DEC);
}
else if(Serial.print(now.second(), DEC) < 10){
lcd.setCursor(11,0);
lcd.print(now.second(), DEC);
lcd.setCursor(10,0);
lcd.print(" ");
}
有人能帮我查一下这个密码吗?
代码应由:
//time displayed on lcd
lcd.setCursor(4, 0);
lcd.print(now.hour(), DEC);
lcd.print(':');
lcd.print(now.minute(), DEC);
lcd.print(':');
if(now.second() >= 10){
lcd.setCursor(10,0);
lcd.print(now.second(), DEC);
}
else if(now.second() < 10){
lcd.setCursor(11,0);
lcd.print(now.second(), DEC);
lcd.setCursor(10,0);
lcd.print(" ");
}
删除if中的Serial.printSerial.print(now.second(),DEC)返回发送到串行端口的字节数。https://www.arduino.cc/en/Serial/Print这里没有用。
相关文章:
- 如何循环打印顶点结构
- 为什么在popback()操作之后,它仍然打印完整的矢量
- 如何在c++中打印目录
- 有一个打印语句的函数是一种糟糕的编程实践吗
- 在线编译器中的分段C++没有打印消息
- 在C++中打印指向不同基元数据类型的指针的内存地址
- 这个指针和内存代码打印是什么?我不知道是打印垃圾还是如何打印我需要的值
- 如何将结构插入到集合中并打印集合的成员
- 在循环C++中指定字符串之后,不会打印该字符串
- 以螺旋方式打印矩阵的程序.(工作不好)
- 从控制台中删除最后打印的元素
- 如何使用Crypto++并为RSA返回可打印的字节/字符数组
- 如何仅使用对象名称打印特定于对象的成员
- 回溯C++不打印函数,因此文件
- 在一定长度后从数组中打印时缺少整数
- 为什么这个 c++ 代码打印出长度 5,当我打印出字符串时,程序会自动终止?
- 在gem5中打印文件中的所有cache_blocks
- 打印数字图案
- 加入两个变量和LCD打印
- LCD和RTC_DS1307-无法正确打印LCD上的1-9位秒数