赞
踩
#include "reg51.h"
#include "lcd1602.h"
#include"i2c.h"
#define uchar unsigned char
#define uint unsigned int
sbit beep=P2^7;//蜂鸣器
sbit led=P3^4;//led
uchar time=0,mode=0;//系统变量
uchar sec=0,miao=0,fen=0,shi=0;//计时
uchar fen1[]={0,0,0,0,0,0};//上下课
uchar shi1[]={0,0,0,0,0,0};
uchar flag=0;//打铃标志
uchar disp[]="00:00:00";
uchar key=0;
uchar key_scan()//按键检测
{
uchar i,j;
i=0;
j=0;
P1=0x0f;
if(P1!=0x0f) //检测有无按下
{
delay_uint(1000);
if(P1!=0x0f) //检测有无按下
{
switch(P1)//检测行
{
case 0x0e:i=3;break;
case 0x0d:i=2;break;
case 0x0b:i=1;break;
case 0x07:i=0;
}
P1=0xf0;
switch(P1)//检测列
{
case 0xe0:j=13;break;
case 0xd0:j=9;break;
case 0xb0:j=5;break;
case 0x70:j=1;
}
}
}
if(key!=i+j)
{
key=i+j;
return key;
}
else
return 0;
}
void main()//主函数
{
uchar i=0;
//初始化存储
fen1[0]=At24c02Read(0);//分钟
if(fen1[0]>59)
{
fen1[0]=1;
At24c02Write(0,fen1[0]);
}
fen1[1]=At24c02Read(1);
if(fen1[1]>59)
{
fen1[1]=2;
At24c02Write(1,fen1[1]);
}
fen1[2]=At24c02Read(2);
if(fen1[2]>59)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。