如何在powertip pc1602f b 16x2 LCD显示模块上显示数字时钟?
我需要在powertip pc1602f b 16x2 LCD显示模块上显示数字时钟的帮助,代码运行良好,但我需要能够在MEL studio 7上运行它。。。我用的是STK300 AVR板,时间显示在液晶屏上。理想情况下,程序应为c/embedded c如何在powertip pc1602f b 16x2 LCD显示模块上显示数字时钟?,c,atmelstudio,C,Atmelstudio,我需要在powertip pc1602f b 16x2 LCD显示模块上显示数字时钟的帮助,代码运行良好,但我需要能够在MEL studio 7上运行它。。。我用的是STK300 AVR板,时间显示在液晶屏上。理想情况下,程序应为c/embedded c /* * A1.c * * Created: 19/10/2018 11:51:29 * Author : mk3101f */ #include <stdio.h> #include <time.h>
/*
* A1.c
*
* Created: 19/10/2018 11:51:29
* Author : mk3101f
*/
#include <stdio.h>
#include <time.h> //for sleep() function
int main(void)
{
int hour, minute, second;
hour=minute=second=0;
while (1)
{
//clear output screen
system("clear");
//print time in HH : MM : SS format
printf("%02d : %02d : %02d ",hour,minute,second);
//clear output buffer in gcc
fflush(stdout);
//increase second
second++;
//update hour, minute and second
if(second==60){
minute+=1;
second=0;
}
if(minute==60){
hour+=1;
minute=0;
}
if(hour==24){
hour=0;
minute=0;
second=0;
}
sleep(1); //wait till 1 second
}
return 0;
}
/*
*A1.c
*
*创建日期:2018年10月19日11:51:29
*作者:mk3101f
*/
#包括
#include//for sleep()函数
内部主(空)
{
整小时,分,秒;
小时=分钟=秒=0;
而(1)
{
//清除输出屏幕
系统(“清除”);
//以HH:MM:SS格式打印时间
printf(“%02d:%02d:%02d”,小时、分钟、秒);
//清除gcc中的输出缓冲区
fflush(stdout);
//增加秒数
第二++;
//更新时、分、秒
如果(秒==60){
分钟+=1;
秒=0;
}
如果(分钟==60){
小时+=1;
分钟=0;
}
如果(小时==24){
小时=0;
分钟=0;
秒=0;
}
睡眠(1);//等待1秒
}
返回0;
}
我需要能在梅尔工作室7号运行它。。。我使用的是STK300 AVR板
基本上,您需要:
- 一种可靠测量时间的方法
- 向显示器发送输出的一种方法
while (true) {
time = read_the_clock();
write_time_to_display(time);
sleep(1);
}
这将为您提供一个更精确的时钟,因为RTC报告的时间不会像控制器那样出现漂移。请正确设置问题格式。这在很大程度上取决于您使用的LCD屏幕。它是一个普通的LCD屏幕,您需要控制HSYNC和VSYNC线路吗。或者LCD屏幕上有像SSD1963这样的控制器芯片吗?扔进一些随机的、不相关的代码并不会让这成为一个代码乞讨的问题。有数百万种不同的液晶显示器,所以你基本上是在问绳子有多长。