易语言与单片机通信 80
我用易语言端口发送6个数据给51单片机收到如图所示时间关灯求大神看看为什么灯不灭#include<reg52.h>#defineucharunsignedchar#def...
我用易语言端口发送6个数据给51单片机收到如图所示时间关灯求大神看看为什么灯不灭
#include<reg52.h>#define uchar unsigned char#define uint unsigned intuchar hour1,minute1,second1,hour2,minute2,second2,read_flag,temp;sbit led=P0^0;void main(){inti();while(1) { if(00==hour1&&00==minute1&&30==second1&&00==hour2&&00==minute2&&30==second2) { led=1 } }}void inti(){ PCON=0x00; TMOD=0x20; TH1=0xfd; TL1=0xfd; TR1=1; REN=1; SM0=0; SM1=1; EA=1; ES=1; read_flag=0;}void ser() interrupt 4{ RI=1; temp=SBUF; RI=0; read_flag++; switch(read_flag) { case 1:hour1=temp; break; case 2:minute1=temp; break; case 3:second1=temp; break; case 4:hour2=temp; break; case 5:minute2=temp; break; case 6:second2=temp; read_flag=0; break; }} 展开
#include<reg52.h>#define uchar unsigned char#define uint unsigned intuchar hour1,minute1,second1,hour2,minute2,second2,read_flag,temp;sbit led=P0^0;void main(){inti();while(1) { if(00==hour1&&00==minute1&&30==second1&&00==hour2&&00==minute2&&30==second2) { led=1 } }}void inti(){ PCON=0x00; TMOD=0x20; TH1=0xfd; TL1=0xfd; TR1=1; REN=1; SM0=0; SM1=1; EA=1; ES=1; read_flag=0;}void ser() interrupt 4{ RI=1; temp=SBUF; RI=0; read_flag++; switch(read_flag) { case 1:hour1=temp; break; case 2:minute1=temp; break; case 3:second1=temp; break; case 4:hour2=temp; break; case 5:minute2=temp; break; case 6:second2=temp; read_flag=0; break; }} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询