遥控定时插座论文(7)

2019-04-23 14:43

附录1 程序

#include #include \#include \#include \#include \

uchar tishi[]={\提示信息 uchar timeovr[]={\

extern signed char second,minute,hour,hour0; extern signed char pmin,phour,ps1;

#define SetTime(H,M,S) {second=S;minute=M;hour=H;hour0=H;} #define CPU_F ((double)8000000) //定义CPU 的时钟频率为8M #define

delay_us(x)

__delay_cycles((long)(CPU_F*(double)x/1000000.0))// 定义延时1us #define

delay_ms(x)

__delay_cycles((long)(CPU_F*(double)x/1000.0)) // 定义延时1ms

#define keyin (P3IN & 0x0f)

#define IR_DIR_IN P1DIR&=~BIT5 //红外接收头P1.5设置为输入

31

#define IRIN (P1IN&BIT5) //红外接收头输入值 uchar keypress,keypress1; char dat[8]; void Clock_Init() {

uchar i;

BCSCTL1&=~XT2OFF; //START XT2(8MHZ) BCSCTL2|=SELM1+SELS;

do{ //等待时钟转换 IFG1&=~OFIFG; for(i=0;i<100;i++) _NOP(); }

while((IFG1&OFIFG)!=0); IFG1&=~OFIFG; }

void keyscan1() {

if(keyin ==0x0e) //如果有键被按下

32

{

Delay5ms(); //延时消抖 if(keyin ==0x0e) //再次检测按键状态 {

keypress++;

while(keyin == 0x0e); //等待按键被放开 if(keypress==1) {

CCTL0&=~CCIE; LocateXY(11,1);

LcdWriteCommand(0x0f,1); }

if(keypress==2) {

LocateXY(8,1); }

if(keypress==3) {

LocateXY(5,1); }

if(keypress==4) {

33

keypress=0;

LcdWriteCommand(0x0c,1); CCTL0|=CCIE; } } }

if(keypress!=0) {

if(keyin ==0x0d) {

//delay(); if(keyin ==0x0d) {

while(keyin==0x0d); if(keypress==1) {

second+=1; if(second==60) second=0; Display(); LocateXY(11,1);

34

}

if(keypress==2) {

minute+=1; if(minute==60) minute=0; Display(); LocateXY(8,1); }

if(keypress==3) {

hour+=1; if(hour==24) hour=0; Display(); LocateXY(5,1); } } }

if(keyin==0x0b) {

// delay();

35


遥控定时插座论文(7).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:中国教育简史题库

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: