[日期:2009-06-11 ] [ 作者:佚名] [字体:大中小] (投递新闻)
连线图:
; DB0--- DB4--- RS-------------
; DB1--- DB5--- RW-------------
; DB2--- DB6--- E--------------
; DB3--- DB7--- VLCD接10K可调电阻到GND*
#include ""//头文件
#include ""
#define uchar unsigned char//宏定义
#define uint unsigned int//宏定义
sbit RS=P1^2;//定义I/O的硬件接口
sbit RW=P1^3;
sbit E=P1^4;
sbit led_1=P1^7;//;;;LED秒闪烁
uchar Hours=0;//定义小时
uchar Minutes=0;//定义分钟
uchar Seconds=0;//定义秒
bit Seconds_Scintillation=1;//定义秒闪烁标志
#define DPDR P0//并行数据接口定义
uchar code DispTab_1[]={'0','1','2','3','4','5','6','7','8','9'};//1602:0-9 数字
uchar code DispTab_2[]={'A','B','C','D','E','a','b','c','d','e'};//1602:A-e 字母
uchar DispBuf[8]; //8字节的显示缓冲区
char char_char_1[]={" "};//定义字符串
char char_char_2[]={" "};//定义空字符串
void delay(uint z)//1ms延时
{
uchar x,x1;
for(;z>0;z--)
{
for(x=0;x<114;x++)
{
for(x1=0;x1<1;x1++);
}
}
}
void Timer0() interrupt 1
{
static uchar Count_50;//
uchar temp;
TH0=0xb7;
TL0=0xff;//定时时间为20ms,每20ms中断一次
Count_50++;
if(Count_50==50)//20ms*50=1秒
{ Seconds_Scintillation=~Seconds_Scintillation;
led_1=~led_1;
Count_50=0;
Seconds++;
if(Seconds==60)
{
Seconds=0;
Minutes++;
if(Minutes==60)
{
Minutes=0;
Hours++;
if(Hours==24)
{
Hours=0;
}
}
}
}
if(Seconds_Scintillation==1)//秒闪烁标志判断
DispBuf[6]=':';
else
Di
1602液晶电子时钟程序51单片机 来自淘豆网www.taodocs.com转载请标明出处.