单片机+1602液晶数字时钟程序
头文件STC12C5A.H下载:http://www.51hei.com/mcu/2564.html
程序:
首先是主程序:
#include
#include "STDIO.h"
#include "LCD1602.h"
#include "interrupt.h"
void main()
{
LCD_init();
interrupts_init();
LCD_disp_cher(0, 1,"784729514 ");
while(1)
{
sprintf(dsa,"%d:%d:%d ",hour,minute,sec);
LCD_disp_cher(0,2,dsa);
}
}
下面是lcd1602.H头文件:http://www.51hei.com/mcu/2965.html
这是另一个头文件 自行保存即可
#ifndef _interrupt_H_
#define _interrupt_H_
#define uint unsigned int
#define uchar unsigned char
uint sec,subtle,minute,hour;
uchar dsa[16];
void interrupts_init()
{
EA=1;
ET0=1;
TR0=1;
TMOD=0x1;
TH0=(65536-50000)/255;
TL0=(65536-50000)%255;
}
void ghjfgf() interrupt 1
{
TH0=(65536-50000)/255;
TL0=(65536-50000)%255;
subtle++;
if(subtle==20)
{
subtle=0;
sec++;
}
if(sec==60)
{
sec=0;
minute++;
}
if(minute==60)
{
minute=0;
hour++;
}
if(hour==24) hour=0;
}
#endif
单片机602液晶数字时 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)