微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 嵌入式设计讨论 > MCU和单片机设计讨论 > 远程火灾报警系统的C语言程序

远程火灾报警系统的C语言程序

时间:10-02 整理:3721RD 点击:

file:///C:\Users\12345\AppData\Local\Temp\ksohtml\wps_clip_image-19134.png[size=14.0000pt]
[size=14.0000pt]附录4 系统总程序
[size=10.5000pt]#include <reg51.h>
[size=10.5000pt]#include <stdio.h>
[size=10.5000pt]#define uchar unsigned char
[size=10.5000pt]#define uint unsigned int
[size=10.5000pt]sbit P0_0=P0^0;
[size=10.5000pt]uchar code dt[]="abc";
[size=10.5000pt]uchar code at[] = "AT";
[size=10.5000pt]uchar code cmgf[]="AT+CMGF=1";
[size=10.5000pt]uchar code csca[]="AT+CSCA=+8613800595500";
[size=10.5000pt]uchar code cmgs[]="AT+CMGS=15159753072";
[size=10.5000pt]uchar code cnmi[]="AT+CNMI=1,1,2;";   //短信提醒
[size=10.5000pt]uchar code cmgr[]="AT+CMGR=1";        //短消息读取命令
[size=10.5000pt]uchar code cmgd[]="AT+CMGD=1";       //删除短信
[size=10.5000pt]uchar code cn[6]="+CMTI";
[size=10.5000pt]uchar code cm[4]="GSM";
[size=10.5000pt]/*******************TC35变量定义**************/
[size=10.5000pt]uchar i_TC35_RECE=0;
[size=10.5000pt]uchar i_receive, TC35_MAX, flag, flag0,flag1=0;
[size=10.5000pt]xdata uchar  TC35_RE[90];
[size=10.5000pt]uchar flag4;
[size=10.5000pt]uchar tltemp;         //临时暂存变量
[size=10.5000pt]uchar  temp_value,temp1_value;      //temp_value温度值正数部分
[size=10.5000pt]xdata uchar  TempBuffer[6];
[size=10.5000pt]/************************变量定义************************/
[size=10.5000pt]uint num,T2=0,TMPL,TMPH,tem;
[size=10.5000pt]uchar tab[5]=0,tab1[4],flag3,h,flag2,flag5,count;
[size=10.5000pt]uchar code str[20]={"bi ye she ji"};
[size=10.5000pt]uchar code str2[10]={"wen  du"};
[size=10.5000pt]uchar code str3[10]={"nong du:"};
[size=10.5000pt]/************************引脚定义*************************/
[size=10.5000pt]sbit lcdrs=P3^7;     //4脚
[size=10.5000pt]sbit lcdrw=P3^6;     //5脚
[size=10.5000pt]sbit lcde=P3^5;      //6脚
[size=10.5000pt]sbit clk=P3^2;
[size=10.5000pt]sbit dataout=P3^3;
[size=10.5000pt]sbit cs=P3^4;
[size=10.5000pt]sbit DQ=P2^0;
[size=10.5000pt]sbit la_ba=P0^0 ;
[size=10.5000pt]/*********************LCD子函数定义*************************/
[size=10.5000pt]void lcdinit(void);                   //lcd初始化
[size=10.5000pt]void lcdsendc(uchar c);               //发送lcd指令
[size=10.5000pt]void lcdsendd(uchar c);               //发送lcd数据
[size=10.5000pt]void lcdbusy(void);                   //判断忙状态
[size=10.5000pt]void delay1ms(uint time);             //延时子程序
[size=10.5000pt]void display(uchar c1,uchar *str);
[size=10.5000pt]void delay1ms(uint time);
[size=10.5000pt]void display_yanwu();
[size=10.5000pt]/*****************采集电压,读取AD转换结果********************/
[size=10.5000pt]unsigned char get_val(void)
[size=10.5000pt]{
[size=10.5000pt]unsigned  i;
[size=10.5000pt]unsigned char T;
[size=10.5000pt]  cs=1;
[size=10.5000pt]  clk=0;
[size=10.5000pt]  cs=0;
[size=10.5000pt] for(i=0;i<8;i++)
[size=10.5000pt] {
[size=10.5000pt]  clk=1;
[size=10.5000pt]  T=T<<1;
[size=10.5000pt]  if(dataout==1)
[size=10.5000pt]  T=T+1;
[size=10.5000pt]  clk=0;}
[size=10.5000pt]  cs=1;
[size=10.5000pt]  return T;
[size=10.5000pt]}
[size=10.5000pt]/***********************烟雾浓度显示*************************/
[size=10.5000pt]void   display_yanwu()
[size=10.5000pt]{     uchar shidu_qian,shidu_bai,shidu_shi,shidu_ge;
[size=10.5000pt]        T2=get_val();
[size=10.5000pt]         num=((float)T2/255)*5000;
[size=10.5000pt]          if(num>4000){flag5=1;}
[size=10.5000pt]         shidu_qian=0x30+num/1000;
[size=10.5000pt]          shidu_bai=0x30+num/100%10;
[size=10.5000pt]          shidu_shi=0x30+num/10%10;
[size=10.5000pt]          shidu_ge=0x30+num%10;
[size=10.5000pt]         tab[0]=shidu_qian;  tab[1]=shidu_bai; tab[2]=shidu_shi; tab[3]=shidu_ge;
[size=10.5000pt]         display(0x88,tab);
[size=10.5000pt]}
[size=10.5000pt]//--------------lcd初始化程序-------------------
[size=10.5000pt]void lcdinit()
[size=10.5000pt]{
[size=10.5000pt]   lcdsendc(0x01);                  //清屏
[size=10.5000pt]   delay1ms(100);
[size=10.5000pt]   lcdsendc(0x3c);                  //8位 2行   5X10字符
[size=10.5000pt]   delay1ms(3);
[size=10.5000pt]   lcdsendc(0x0e);                  //开启显示,光标显示,字符闪烁关闭
[size=10.5000pt]   lcdsendc(0x02);                  //光标归位
[size=10.5000pt]   delay1ms(2);
[size=10.5000pt]   }
[size=10.5000pt]//----------------发送lcd命令---------------------
[size=10.5000pt]void lcdsendc(uchar c)
[size=10.5000pt]{
[size=10.5000pt]   P1=c;
[size=10.5000pt]   lcdrs=0;
[size=10.5000pt]   lcdrw=0;
[size=10.5000pt]   lcde=0;
[size=10.5000pt]   lcdbusy();
[size=10.5000pt]   lcde=1;
[size=10.5000pt]   if(c==1)
[size=10.5000pt]     delay1ms(2);
[size=10.5000pt]   }
[size=10.5000pt]//-----------------发送数据----------------------
[size=10.5000pt]void lcdsendd(uchar c)
[size=10.5000pt]{
[size=10.5000pt]   P1=c;
[size=10.5000pt]   lcdrs=1;
[size=10.5000pt]   lcdrw=0;
[size=10.5000pt]   lcde=0;
[size=10.5000pt]   lcdbusy();
[size=10.5000pt]   lcde=1;
[size=10.5000pt]   }
[size=10.5000pt]//------------------判断忙状态--------------------
[size=10.5000pt]void lcdbusy()
[size=10.5000pt]{
[size=10.5000pt]   P1=0xff;
[size=10.5000pt]   lcdrs=0;
[size=10.5000pt]   lcdrw=1;
[size=10.5000pt]   lcde=0;
[size=10.5000pt]   lcde=0;
[size=10.5000pt]   lcde=1;
[size=10.5000pt]   //delay1ms(1);
[size=10.5000pt]   while((P1&0x80)==1);
[size=10.5000pt]   }
[size=10.5000pt]//------------------延时子程序----------------------
[size=10.5000pt]void delay1ms(uint time)
[size=10.5000pt]{
[size=10.5000pt]   uint i,j;
[size=10.5000pt]   for(i=0;i<time;i++)
[size=10.5000pt]   for(j=0;j<100;j++);
[size=10.5000pt]   }
[size=10.5000pt]//-----------------显示子程序---------------------------
[size=10.5000pt]void display(uchar c1,uchar *str)
[size=10.5000pt]{ uchar a;
[size=10.5000pt]  a=c1 ;
[size=10.5000pt]  lcdsendc(a);
[size=10.5000pt]   while((*str)!= '\0')
[size=10.5000pt]    {
[size=10.5000pt]         lcdsendd(*str);
[size=10.5000pt]         delay1ms(3);
[size=10.5000pt]         str++;
[size=10.5000pt]     }
[size=10.5000pt]}
[size=10.5000pt]/***************us级延时函数*****************/
[size=10.5000pt]void delay2(unsigned int num)
[size=10.5000pt]{
[size=10.5000pt]  while( --num ) ;
[size=10.5000pt]}
[size=10.5000pt]/***************ds18b20模块********************/
[size=10.5000pt]Reset_DS18B20(void)          //复位ds1820
[size=10.5000pt]{    DQ = 1 ;                //DQ复位
[size=10.5000pt]     delay2(8) ;             //稍做延时
[size=10.5000pt]     DQ = 0 ;                 //单片机将DQ拉低
[size=10.5000pt]     delay2(90) ;             //精确延时 大于 480us
[size=10.5000pt]     DQ = 1 ;                 //拉高总线
[size=10.5000pt]     delay2(8) ;
[size=10.5000pt]     flag3 = DQ ;             //如果=0则初始化成功 =1则初始化失败
[size=10.5000pt]     delay2(50) ;
[size=10.5000pt]     DQ = 1 ;
[size=10.5000pt]     return(flag3) ;          //返回信号,0=presence,1= no presence
[size=10.5000pt]}
[size=10.5000pt]/***************** 读一个字节*************************/
[size=10.5000pt] ReadOneChar(void)
[size=10.5000pt]{
[size=10.5000pt]unsigned char i = 0 ;
[size=10.5000pt]unsigned char dat = 0 ;
[size=10.5000pt]for (i = 8 ; i > 0 ; i--)
[size=10.5000pt]  {
[size=10.5000pt]    DQ = 0 ;                   // 给脉冲信号
[size=10.5000pt]    dat >>= 1 ;
[size=10.5000pt]    DQ = 1 ;                   // 给脉冲信号
[size=10.5000pt]    if(DQ)
[size=10.5000pt]     dat |= 0x80 ;
[size=10.5000pt]    delay2(4) ;
[size=10.5000pt]  }
[size=10.5000pt]    return (dat) ;
[size=10.5000pt]}
[size=10.5000pt]/***************************写一个字节****************************/
[size=10.5000pt]
[size=10.5000pt] WriteOneChar(unsigned char dat)
[size=10.5000pt]{
[size=10.5000pt]  unsigned char i = 0 ;
[size=10.5000pt]  for (i = 8 ; i > 0 ; i--)
[size=10.5000pt]  {
[size=10.5000pt]    DQ = 0 ;
[size=10.5000pt]    DQ = dat&0x01 ;
[size=10.5000pt]    delay2(5) ;
[size=10.5000pt]    DQ = 1 ;
[size=10.5000pt]    dat>>=1 ;
[size=10.5000pt]  }
[size=10.5000pt]}
[size=10.5000pt]/**********************DS18B20初始化************************/
[size=10.5000pt]
[size=10.5000pt]Init_DS18B20(void)
[size=10.5000pt]{
[size=10.5000pt]     Reset_DS18B20();
[size=10.5000pt]     WriteOneChar(0xCC) ;     // 跳过读序号列号的操作
[size=10.5000pt]     WriteOneChar(0x4E) ;     // 将数据写入暂存器的第2.3字节中
[size=10.5000pt]     WriteOneChar(0x7f) ;     //分辨率配置值.
[size=10.5000pt]}
[size=10.5000pt]
[size=10.5000pt]/**********************读取温度*************************/
[size=10.5000pt] Read_Temperature(void)
[size=10.5000pt]{
[size=10.5000pt]     uchar TH=0;
[size=10.5000pt]    uchar TL=0;
[size=10.5000pt]    flag4=0;
[size=10.5000pt]     Reset_DS18B20() ;
[size=10.5000pt]    WriteOneChar(0xCC) ;                // 跳过读序号列号的操作
[size=10.5000pt]     WriteOneChar(0x44) ;                // 启动温度转换
[size=10.5000pt]     Reset_DS18B20() ;
[size=10.5000pt]     WriteOneChar(0xCC) ;                //跳过读序号列号的操作
[size=10.5000pt]     WriteOneChar(0xBE) ;                //读取温度寄存器
[size=10.5000pt]     TL=ReadOneChar();         //温度低8位
[size=10.5000pt]      TH=ReadOneChar();        //温度高8位
[size=10.5000pt]       if((TH&0xf8)!=0x00)      //是负温度
[size=10.5000pt]  {
[size=10.5000pt]    flag4=1;
[size=10.5000pt]    TH=~TH;
[size=10.5000pt]    TL=~TL;
[size=10.5000pt]    tltemp=TL+1;
[size=10.5000pt]    if(tltemp>255)
[size=10.5000pt]    TH++;
[size=10.5000pt]  }        //25.125
[size=10.5000pt]  temp_value=TH*16+TL/16;  //整数
[size=10.5000pt]  temp1_value=(TL%16)*10/16; //小数部分
[size=10.5000pt]}
[size=10.5000pt]void Temp2Str(void)
[size=10.5000pt]{
[size=10.5000pt]  TempBuffer[0]=':';
[size=10.5000pt]  if(flag4==1)   //是负温度
[size=10.5000pt]  {
[size=10.5000pt]   TempBuffer[1]='-';
[size=10.5000pt]  }
[size=10.5000pt]  else
[size=10.5000pt]  {
[size=10.5000pt]   TempBuffer[1]=temp_value/100+'0';
[size=10.5000pt] if(TempBuffer[1]=='0')
[size=10.5000pt] {
[size=10.5000pt]   TempBuffer[1]=' ';
[size=10.5000pt] }
[size=10.5000pt] else
[size=10.5000pt] TempBuffer[1]='1';
[size=10.5000pt]  }
[size=10.5000pt]  TempBuffer[2]=temp_value%100/10+'0';
[size=10.5000pt]  TempBuffer[3]=temp_value%10+'0';
[size=10.5000pt]  TempBuffer[4]='.';
[size=10.5000pt]  TempBuffer[5]=temp1_value+'0';
[size=10.5000pt]  TempBuffer[6]='\0';
[size=10.5000pt]}
[size=10.5000pt]     /* TMPH<<=8;
[size=10.5000pt]      TMPL|=TMPH;
[size=10.5000pt]      tem=TMPL;
[size=10.5000pt]      tt=tem*0.0625;
[size=10.5000pt]      return(tt);                          //返回温度值
[size=10.5000pt]}  */
[size=10.5000pt]
[size=10.5000pt]/*******************************************************************/
[size=10.5000pt] /*Disp_Temperature()
[size=10.5000pt]{
[size=10.5000pt]     uchar dd;
[size=10.5000pt]     dd=Read_Temperature();
[size=10.5000pt]     tab1[0]=0x30+dd/10;
[size=10.5000pt]     tab1[1]=0x30+dd%10;
[size=10.5000pt]     display(0xc6,tab1);
[size=10.5000pt]}   */
[size=10.5000pt]/*******************串口初始化****************/
[size=10.5000pt]void uart_init()
[size=10.5000pt]{
[size=10.5000pt] SCON=0x50;  //允许接收
[size=10.5000pt] PCON=0x00;  //波特率不加倍
[size=10.5000pt] TMOD|=0x21;   //定时器1方式2、定时器0方式1
[size=10.5000pt] TH1=0xfd;   // 波特率设置为9600
[size=10.5000pt] TL1=0xfd;
[size=10.5000pt] TR1=1;
[size=10.5000pt] ES=1;
[size=10.5000pt] EA=1;
[size=10.5000pt] }
[size=10.5000pt]void  timer0_init()
[size=10.5000pt]{
[size=10.5000pt] TL0=0xb0;
[size=10.5000pt] TH0=0x3c;
[size=10.5000pt] ET0=1;
[size=10.5000pt]}
[size=10.5000pt]void delay(uint z)
[size=10.5000pt]{
[size=10.5000pt]        [size=10.5000pt]uint x,y;
[size=10.5000pt]        [size=10.5000pt]for(x=z;x>0;x--)for(y=110;y>0;y--);
[size=10.5000pt]}
[size=10.5000pt]/*****************串口发送字符*****************/
[size=10.5000pt]void send_uart( unsigned char ch)
[size=10.5000pt]         {
[size=10.5000pt]            SBUF=ch;
[size=10.5000pt]            while (!TI);
[size=10.5000pt]               TI= 0 ;
[size=10.5000pt]          }
[size=10.5000pt]void   send(uchar *tab)
[size=10.5000pt]{
[size=10.5000pt]    while((*tab)!= '\0')
[size=10.5000pt]    {
[size=10.5000pt]            SBUF =*tab;
[size=10.5000pt]            while(TI ==0);
[size=10.5000pt]            TI = 0;
[size=10.5000pt]            tab++;
[size=10.5000pt]     }
[size=10.5000pt]       send_uart(0x0D);
[size=10.5000pt]    send_uart(0X0A);
[size=10.5000pt]}
[size=10.5000pt]/*******************清除TC35_RE缓存**********/
[size=10.5000pt]void ClrT35_re()
[size=10.5000pt]{
[size=10.5000pt]   uchar i;
[size=10.5000pt]   for(i=0;i<=TC35_MAX;i++)   TC35_RE=0;
[size=10.5000pt]   i_TC35_RECE=0;
[size=10.5000pt]   TC35_MAX=0;
[size=10.5000pt]
[size=10.5000pt]}
[size=10.5000pt]char find_str( char *str1, char *str2)
[size=10.5000pt]{[size=10.5000pt]        [size=10.5000pt]char index;
[size=10.5000pt]        char find_index;
[size=10.5000pt]        if( str1 == NULL || str2 == NULL)[size=10.5000pt]        [size=10.5000pt]{return 0;}
[size=10.5000pt]        else
[size=10.5000pt]   {    index = 0;
[size=10.5000pt]        while((*(str1 + index) )!= '\0')
[size=10.5000pt]     {
[size=10.5000pt]         find_index = 0;
[size=10.5000pt]         while(1)
[size=10.5000pt]       {
[size=10.5000pt]          if(*(str1 + index + find_index) == *(str2 + find_index))
[size=10.5000pt]          {
[size=10.5000pt]             if((*(str1 + index + find_index)=='\0')&&(*(str2 + find_index)=='\0'))  return 1;
[size=10.5000pt]              find_index++;
[size=10.5000pt]                             }
[size=10.5000pt]          else
[size=10.5000pt]          {
[size=10.5000pt]          if(*(str2 + find_index) == '\0')       return 1; //字符串比对完成返回1
[size=10.5000pt]                [size=10.5000pt]        [size=10.5000pt]else break;
[size=10.5000pt]          }
[size=10.5000pt]       }
[size=10.5000pt]                        index++;
[size=10.5000pt]     }
[size=10.5000pt]   }[size=10.5000pt]        [size=10.5000pt]        return 0;
[size=10.5000pt]}
[size=10.5000pt]/*****************ok应答**********************/
[size=10.5000pt]void TC35_ok()
[size=10.5000pt]{
[size=10.5000pt] delay(800);
[size=10.5000pt]   ClrT35_re();
[size=10.5000pt]}
[size=10.5000pt]/******************串口中断******************/
[size=10.5000pt]void serial() interrupt 4
[size=10.5000pt] {
[size=10.5000pt]     ES=0;
[size=10.5000pt]    if (RI)
[size=10.5000pt]      {
[size=10.5000pt]        RI = 0 ;
[size=10.5000pt]        i_receive=SBUF;
[size=10.5000pt]        TC35_RE[i_TC35_RECE++]=i_receive;
[size=10.5000pt]      if(i_TC35_RECE>TC35_MAX)
[size=10.5000pt]        {
[size=10.5000pt]         TC35_MAX=i_TC35_RECE;
[size=10.5000pt]         if(TC35_MAX>10) flag0=1;
[size=10.5000pt]         }
[size=10.5000pt]    }
[size=10.5000pt]     ES=1;
[size=10.5000pt]}
[size=10.5000pt]/*********************发送短信*********************/
[size=10.5000pt]void TX_SMS(uchar *cc,uchar *dd )
[size=10.5000pt]{
[size=10.5000pt]   send(at);
[size=10.5000pt]   TC35_ok();
[size=10.5000pt]   send(cmgf);
[size=10.5000pt]   TC35_ok();
[size=10.5000pt]   send(csca);
[size=10.5000pt]    TC35_ok();
[size=10.5000pt]   send(cmgs);
[size=10.5000pt]    delay(100);       //100ms
[size=10.5000pt]   send(cc);
[size=10.5000pt]    delay(100);
[size=10.5000pt]    send(dd);
[size=10.5000pt]    delay(100);
[size=10.5000pt]   send_uart(0x1A);
[size=10.5000pt]   send_uart(0x0D);      //回车键
[size=10.5000pt]   send_uart(0x0A);
[size=10.5000pt]    TC35_ok();
[size=10.5000pt]}
[size=10.5000pt]/*********************接收短信*********************/
[size=10.5000pt]
[size=10.5000pt]void  RE_SMS()
[size=10.5000pt]{   char k;
[size=10.5000pt]     if(flag0==1)
[size=10.5000pt]   {   delay(100);
[size=10.5000pt]      k=find_str(TC35_RE,cn);
[size=10.5000pt]      flag0=0;
[size=10.5000pt]      if((k==1))
[size=10.5000pt]      {
[size=10.5000pt]      ClrT35_re();
[size=10.5000pt]      k=0;
[size=10.5000pt]      flag1=1;
[size=10.5000pt]      }
[size=10.5000pt]   }
[size=10.5000pt]   if(flag1==1)
[size=10.5000pt]     {
[size=10.5000pt]      flag1=0;
[size=10.5000pt]      send(cmgr);
[size=10.5000pt]      delay(1500);
[size=10.5000pt]      if((TC35_RE[74]=='a'&&TC35_RE[75]=='9')||(TC35_RE[72]=='a'&&TC35_RE[73]=='9'))
[size=10.5000pt]                                                         { flag=1; send(cmgd); TC35_ok();}
[size=10.5000pt]       else {send(cmgd); TC35_ok();  delay(500); TX_SMS(cm,cm); delay(1000);
[size=10.5000pt] }
[size=10.5000pt]     }
[size=10.5000pt]     if(flag==1)
[size=10.5000pt]     {
[size=10.5000pt]       flag=0;
[size=10.5000pt]       delay(500);
[size=10.5000pt]        TX_SMS(cn,cn);
[size=10.5000pt]        delay(1000);
[size=10.5000pt]     }
[size=10.5000pt] }
[size=10.5000pt]
[size=10.5000pt]/*****************TC35初始化**********************/
[size=10.5000pt]void TC35_init()
[size=10.5000pt]{
[size=10.5000pt]   send(at);
[size=10.5000pt]   TC35_ok();
[size=10.5000pt]   send(cmgf);
[size=10.5000pt]   TC35_ok();
[size=10.5000pt]   send(cmgd);
[size=10.5000pt]   TC35_ok();
[size=10.5000pt]   send(cnmi);
[size=10.5000pt]   delay(400);
[size=10.5000pt]   TC35_ok();
[size=10.5000pt]   delay1ms(2000);
[size=10.5000pt]}
[size=10.5000pt]/********************主函数**********************/
[size=10.5000pt]
[size=10.5000pt] void main()
[size=10.5000pt] {
[size=10.5000pt]   lcdsendc(0x01);
[size=10.5000pt]   lcdinit();
[size=10.5000pt]   display(0x80,str);
[size=10.5000pt]   Init_DS18B20();
[size=10.5000pt]   uart_init();
[size=10.5000pt]    timer0_init();
[size=10.5000pt]   delay(1);
[size=10.5000pt]   TC35_init();
[size=10.5000pt]   TR0=1;
[size=10.5000pt]  lcdsendc(0x01);
[size=10.5000pt]  delay1ms(1);
[size=10.5000pt]  while(1)
[size=10.5000pt]  {
[size=10.5000pt]   if(flag2==1)
[size=10.5000pt]   {
[size=10.5000pt]    flag2=0;
[size=10.5000pt]    display(0x80,str3);
[size=10.5000pt]   display_yanwu();
[size=10.5000pt]   delay1ms(5);
[size=10.5000pt]   Read_Temperature();
[size=10.5000pt]   Temp2Str();
[size=10.5000pt]    display(0xc0,str2);
[size=10.5000pt]   display(0xc7,TempBuffer);
[size=10.5000pt]    delay1ms(5);
[size=10.5000pt]    }
[size=10.5000pt]    if(flag5==1){la_ba=0; TR0=0;TX_SMS(cm,cm);flag5=0; TR0=1;}
[size=10.5000pt]
[size=10.5000pt]   // RE_SMS();
[size=10.5000pt]  }
[size=10.5000pt] }
[size=10.5000pt]  void timer0() interrupt 1
[size=10.5000pt] {
[size=10.5000pt]     h++;
[size=10.5000pt]     TF0=0;
[size=10.5000pt]    TR0=0;
[size=10.5000pt]    TL0=0xb0;
[size=10.5000pt]    TH0=0x3c;
[size=10.5000pt]     if(h==40)
[size=10.5000pt]   { h=0;flag2=1;P0_0=1;}
[size=10.5000pt]      TR0=1;
[size=10.5000pt]  }

新人看不太懂,希望小编多发点消防报警的帖子

学习一下。

le:///C:\Users\12345\AppData\Local\Temp\ksohtml\wps_clip_image-19134.png[size=14.0000pt]
[size=14.0000pt]附录4 系统总程序
[size=10.5000pt]#include <reg51.h>
[size=10.5000pt]#include <stdio.h>
[size=10.5000pt]#define uchar unsigned char
[size=10.5000pt]#define uint unsigned int
[size=10.5000pt]sbit P0_0=P0^0;
[size=10.5000pt]uchar code dt[]="abc";
[size=10.5000pt]uchar code at[] = "AT";
[size=10.5000pt]uchar code cmgf[]="AT+CMGF=1";
[size=10.5000pt]uchar code csca[]="AT+CSCA=+8613800595500";
[size=10.5000pt]uchar code cmgs[]="AT+CMGS=15159753072";
[size=10.5000pt]uchar code cnmi[]="AT+CNMI=1,1,2;";   //短信提醒
[size=10.5000pt]uchar code cmgr[]="AT+CMGR=1";        //短消息读取命令
[size=10.5000pt]uchar code cmgd[]="AT+CMGD=1";       //删除短信
[size=10.5000pt]uchar code cn[6]="+CMTI";
[size=10.5000pt]uchar code cm[4]="GSM";
[size=10.5000pt]/*******************TC35变量定义**************/
[size=10.5000pt]uchar i_TC35_RECE=0;
[size=10.5000pt]uchar i_receive, TC35_MAX, flag, flag0,flag1=0;
[size=10.5000pt]xdata uchar  TC35_RE[90];
[size=10.5000pt]uchar flag4;
[size=10.5000pt]uchar tltemp;         //临时暂存变量
[size=10.5000pt]uchar  temp_value,temp1_value;      //temp_value温度值正数部分
[size=10.5000pt]xdata uchar  TempBuffer[6];
[size=10.5000pt]/************************变量定义************************/
[size=10.5000pt]uint num,T2=0,TMPL,TMPH,tem;
[size=10.5000pt]uchar tab[5]=0,tab1[4],flag3,h,flag2,flag5,count;
[size=10.5000pt]uchar code str[20]={"bi ye she ji"};
[size=10.5000pt]uchar code str2[10]={"wen  du"};
[size=10.5000pt]uchar code str3[10]={"nong du:"};
[size=10.5000pt]/************************引脚定义*************************/
[size=10.5000pt]sbit lcdrs=P3^7;     //4脚
[size=10.5000pt]sbit lcdrw=P3^6;     //5脚
[size=10.5000pt]sbit lcde=P3^5;      //6脚
[size=10.5000pt]sbit clk=P3^2;
[size=10.5000pt]sbit dataout=P3^3;
[size=10.5000pt]sbit cs=P3^4;
[size=10.5000pt]sbit DQ=P2^0;
[size=10.5000pt]sbit la_ba=P0^0 ;
[size=10.5000pt]/*********************LCD子函数定义*************************/
[size=10.5000pt]void lcdinit(void);                   //lcd初始化
[size=10.5000pt]void lcdsendc(uchar c);               //发送lcd指令
[size=10.5000pt]void lcdsendd(uchar c);               //发送lcd数据
[size=10.5000pt]void lcdbusy(void);                   //判断忙状态
[size=10.5000pt]void delay1ms(uint time);             //延时子程序
[size=10.5000pt]void display(uchar c1,uchar *str);
[size=10.5000pt]void delay1ms(uint time);
[size=10.5000pt]void display_yanwu();
[size=10.5000pt]/*****************采集电压,读取AD转换结果********************/
[size=10.5000pt]unsigned char get_val(void)
[size=10.5000pt]{
[size=10.5000pt]unsigned  i;
[size=10.5000pt]unsigned char T;
[size=10.5000pt]  cs=1;
[size=10.5000pt]  clk=0;
[size=10.5000pt]  cs=0;
[size=10.5000pt] for(i=0;i<8;i++)
[size=10.5000pt] {
[size=10.5000pt]  clk=1;
[size=10.5000pt]  T=T<<1;
[size=10.5000pt]  if(dataout==1)
[size=10.5000pt]  T=T+1;
[size=10.5000pt]  clk=0;}
[size=10.5000pt]  cs=1;
[size=10.5000pt]  return T;
[size=10.5000pt]}
[size=10.5000pt]/***********************烟雾浓度显示*************************/
[size=10.5000pt]void   display_yanwu()
[size=10.5000pt]{     uchar shidu_qian,shidu_bai,shidu_shi,shidu_ge;
[size=10.5000pt]        T2=get_val();
[size=10.5000pt]         num=((float)T2/255)*5000;
[size=10.5000pt]          if(num>4000){flag5=1;}
[size=10.5000pt]         shidu_qian=0x30+num/1000;
[size=10.5000pt]          shidu_bai=0x30+num/100%10;
[size=10.5000pt]          shidu_shi=0x30+num/10%10;
[size=10.5000pt]          shidu_ge=0x30+num%10;
[size=10.5000pt]         tab[0]=shidu_qian;  tab[1]=shidu_bai; tab[2]=shidu_shi; tab[3]=shidu_ge;
[size=10.5000pt]         display(0x88,tab);
[size=10.5000pt]}
[size=10.5000pt]//--------------lcd初始化程序-------------------
[size=10.5000pt]void lcdinit()
[size=10.5000pt]{
[size=10.5000pt]   lcdsendc(0x01);                  //清屏
[size=10.5000pt]   delay1ms(100);
[size=10.5000pt]   lcdsendc(0x3c);                  //8位 2行   5X10字符
[size=10.5000pt]   delay1ms(3);
[size=10.5000pt]   lcdsendc(0x0e);                  //开启显示,光标显示,字符闪烁关闭
[size=10.5000pt]   lcdsendc(0x02);                  //光标归位
[size=10.5000pt]   delay1ms(2);
[size=10.5000pt]   }
[size=10.5000pt]//----------------发送lcd命令---------------------
[size=10.5000pt]void lcdsendc(uchar c)
[size=10.5000pt]{
[size=10.5000pt]   P1=c;
[size=10.5000pt]   lcdrs=0;
[size=10.5000pt]   lcdrw=0;
[size=10.5000pt]   lcde=0;
[size=10.5000pt]   lcdbusy();
[size=10.5000pt]   lcde=1;
[size=10.5000pt]   if(c==1)
[size=10.5000pt]     delay1ms(2);
[size=10.5000pt]   }
[size=10.5000pt]//-----------------发送数据----------------------
[size=10.5000pt]void lcdsendd(uchar c)
[size=10.5000pt]{
[size=10.5000pt]   P1=c;
[size=10.5000pt]   lcdrs=1;
[size=10.5000pt]   lcdrw=0;
[size=10.5000pt]   lcde=0;
[size=10.5000pt]   lcdbusy();
[size=10.5000pt]   lcde=1;
[size=10.5000pt]   }
[size=10.5000pt]//------------------判断忙状态--------------------
[size=10.5000pt]void lcdbusy()
[size=10.5000pt]{
[size=10.5000pt]   P1=0xff;
[size=10.5000pt]   lcdrs=0;
[size=10.5000pt]   lcdrw=1;
[size=10.5000pt]   lcde=0;
[size=10.5000pt]   lcde=0;
[size=10.5000pt]   lcde=1;
[size=10.5000pt]   //delay1ms(1);
[size=10.5000pt]   while((P1&0x80)==1);
[size=10.5000pt]   }
[size=10.5000pt]//------------------延时子程序----------------------
[size=10.5000pt]void delay1ms(uint time)
[size=10.5000pt]{
[size=10.5000pt]   uint i,j;
[size=10.5000pt]   for(i=0;i<time;i++)
[size=10.5000pt]   for(j=0;j<100;j++);
[size=10.5000pt]   }
[size=10.5000pt]//-----------------显示子程序---------------------------
[size=10.5000pt]void display(uchar c1,uchar *str)
[size=10.5000pt]{ uchar a;
[size=10.5000pt]  a=c1 ;
[size=10.5000pt]  lcdsendc(a);
[size=10.5000pt]   while((*str)!= '\0')
[size=10.5000pt]    {
[size=10.5000pt]         lcdsendd(*str);
[size=10.5000pt]         delay1ms(3);
[size=10.5000pt]         str++;
[size=10.5000pt]     }
[size=10.5000pt]}
[size=10.5000pt]/***************us级延时函数*****************/
[size=10.5000pt]void delay2(unsigned int num)
[size=10.5000pt]{
[size=10.5000pt]  while( --num ) ;
[size=10.5000pt]}
[size=10.5000pt]/***************ds18b20模块********************/
[size=10.5000pt]Reset_DS18B20(void)          //复位ds1820
[size=10.5000pt]{    DQ = 1 ;                //DQ复位
[size=10.5000pt]     delay2(8) ;             //稍做延时
[size=10.5000pt]     DQ = 0 ;                 //单片机将DQ拉低
[size=10.5000pt]     delay2(90) ;             //精确延时 大于 480us
[size=10.5000pt]     DQ = 1 ;                 //拉高总线
[size=10.5000pt]     delay2(8) ;
[size=10.5000pt]     flag3 = DQ ;             //如果=0则初始化成功 =1则初始化失败
[size=10.5000pt]     delay2(50) ;
[size=10.5000pt]     DQ = 1 ;
[size=10.5000pt]     return(flag3) ;          //返回信号,0=presence,1= no presence
[size=10.5000pt]}
[size=10.5000pt]/***************** 读一个字节*************************/
[size=10.5000pt] ReadOneChar(void)
[size=10.5000pt]{
[size=10.5000pt]unsigned char i = 0 ;
[size=10.5000pt]unsigned char dat = 0 ;
[size=10.5000pt]for (i = 8 ; i > 0 ; i--)
[size=10.5000pt]  {
[size=10.5000pt]    DQ = 0 ;                   // 给脉冲信号
[size=10.5000pt]    dat >>= 1 ;
[size=10.5000pt]    DQ = 1 ;                   // 给脉冲信号
[size=10.5000pt]    if(DQ)
[size=10.5000pt]     dat |= 0x80 ;
[size=10.5000pt]    delay2(4) ;
[size=10.5000pt]  }
[size=10.5000pt]    return (dat) ;
[size=10.5000pt]}
[size=10.5000pt]/***************************写一个字节****************************/
[size=10.5000pt]
[size=10.5000pt] WriteOneChar(unsigned char dat)
[size=10.5000pt]{
[size=10.5000pt]  unsigned char i = 0 ;
[size=10.5000pt]  for (i = 8 ; i > 0 ; i--)
[size=10.5000pt]  {
[size=10.5000pt]    DQ = 0 ;
[size=10.5000pt]    DQ = dat&0x01 ;
[size=10.5000pt]    delay2(5) ;
[size=10.5000pt]    DQ = 1 ;
[size=10.5000pt]    dat>>=1 ;
[size=10.5000pt]  }
[size=10.5000pt]}
[size=10.5000pt]/**********************DS18B20初始化************************/
[size=10.5000pt]
[size=10.5000pt]Init_DS18B20(void)
[size=10.5000pt]{
[size=10.5000pt]     Reset_DS18B20();
[size=10.5000pt]     WriteOneChar(0xCC) ;     // 跳过读序号列号的操作
[size=10.5000pt]     WriteOneChar(0x4E) ;     // 将数据写入暂存器的第2.3字节中
[size=10.5000pt]     WriteOneChar(0x7f) ;     //分辨率配置值.
[size=10.5000pt]}
[size=10.5000pt]
[size=10.5000pt]/**********************读取温度*************************/
[size=10.5000pt] Read_Temperature(void)
[size=10.5000pt]{
[size=10.5000pt]     uchar TH=0;
[size=10.5000pt]    uchar TL=0;
[size=10.5000pt]    flag4=0;
[size=10.5000pt]     Reset_DS18B20() ;
[size=10.5000pt]    WriteOneChar(0xCC) ;                // 跳过读序号列号的操作
[size=10.5000pt]     WriteOneChar(0x44) ;                // 启动温度转换
[size=10.5000pt]     Reset_DS18B20() ;
[size=10.5000pt]     WriteOneChar(0xCC) ;                //跳过读序号列号的操作
[size=10.5000pt]     WriteOneChar(0xBE) ;                //读取温度寄存器
[size=10.5000pt]     TL=ReadOneChar();         //温度低8位
[size=10.5000pt]      TH=ReadOneChar();        //温度高8位
[size=10.5000pt]       if((TH&0xf8)!=0x00)      //是负温度
[size=10.5000pt]  {
[size=10.5000pt]    flag4=1;
[size=10.5000pt]    TH=~TH;
[size=10.5000pt]    TL=~TL;
[size=10.5000pt]    tltemp=TL+1;
[size=10.5000pt]    if(tltemp>255)
[size=10.5000pt]    TH++;
[size=10.5000pt]  }        //25.125
[size=10.5000pt]  temp_value=TH*16+TL/16;  //整数
[size=10.5000pt]  temp1_value=(TL%16)*10/16; //小数部分
[size=10.5000pt]}
[size=10.5000pt]void Temp2Str(void)
[size=10.5000pt]{
[size=10.5000pt]  TempBuffer[0]=':';
[size=10.5000pt]  if(flag4==1)   //是负温度
[size=10.5000pt]  {
[size=10.5000pt]   TempBuffer[1]='-';
[size=10.5000pt]  }
[size=10.5000pt]  else
[size=10.5000pt]  {
[size=10.5000pt]   TempBuffer[1]=temp_value/100+'0';
[size=10.5000pt] if(TempBuffer[1]=='0')
[size=10.5000pt] {
[size=10.5000pt]   TempBuffer[1]=' ';
[size=10.5000pt] }
[size=10.5000pt] else
[size=10.5000pt] TempBuffer[1]='1';
[size=10.5000pt]  }
[size=10.5000pt]  TempBuffer[2]=temp_value%100/10+'0';
[size=10.5000pt]  TempBuffer[3]=temp_value%10+'0';
[size=10.5000pt]  TempBuffer[4]='.';
[size=10.5000pt]  TempBuffer[5]=temp1_value+'0';
[size=10.5000pt]  TempBuffer[6]='\0';
[size=10.5000pt]}
[size=10.5000pt]     /* TMPH<<=8;
[size=10.5000pt]      TMPL|=TMPH;
[size=10.5000pt]      tem=TMPL;
[size=10.5000pt]      tt=tem*0.0625;
[size=10.5000pt]      return(tt);                          //返回温度值
[size=10.5000pt]}  */
[size=10.5000pt]
[size=10.5000pt]/*******************************************************************/
[size=10.5000pt] /*Disp_Temperature()
[size=10.5000pt]{
[size=10.5000pt]     uchar dd;
[size=10.5000pt]     dd=Read_Temperature();
[size=10.5000pt]     tab1[0]=0x30+dd/10;
[size=10.5000pt]     tab1[1]=0x30+dd%10;
[size=10.5000pt]     display(0xc6,tab1);
[size=10.5000pt]}   */
[size=10.5000pt]/*******************串口初始化****************/
[size=10.5000pt]void uart_init()
[size=10.5000pt]{
[size=10.5000pt] SCON=0x50;  //允许接收
[size=10.5000pt] PCON=0x00;  //波特率不加倍
[size=10.5000pt] TMOD|=0x21;   //定时器1方式2、定时器0方式1
[size=10.5000pt] TH1=0xfd;   // 波特率设置为9600
[size=10.5000pt] TL1=0xfd;
[size=10.5000pt] TR1=1;
[size=10.5000pt] ES=1;
[size=10.5000pt] EA=1;
[size=10.5000pt] }
[size=10.5000pt]void  timer0_init()
[size=10.5000pt]{
[size=10.5000pt] TL0=0xb0;
[size=10.5000pt] TH0=0x3c;
[size=10.5000pt] ET0=1;
[size=10.5000pt]}
[size=10.5000pt]void delay(uint z)
[size=10.5000pt]{
[size=10.5000pt]        [size=10.5000pt]uint x,y;
[size=10.5000pt]        [size=10.5000pt]for(x=z;x>0;x--)for(y=110;y>0;y--);
[size=10.5000pt]}
[size=10.5000pt]/*****************串口发送字符*****************/
[size=10.5000pt]void send_uart( unsigned char ch)
[size=10.5000pt]         {
[size=10.5000pt]            SBUF=ch;
[size=10.5000pt]            while (!TI);
[size=10.5000pt]               TI= 0 ;
[size=10.5000pt]          }
[size=10.5000pt]void   send(uchar *tab)
[size=10.5000pt]{
[size=10.5000pt]    while((*tab)!= '\0')
[size=10.5000pt]    {
[size=10.5000pt]            SBUF =*tab;
[size=10.5000pt]            while(TI ==0);
[size=10.5000pt]            TI = 0;
[size=10.5000pt]            tab++;
[size=10.5000pt]     }
[size=10.5000pt]       send_uart(0x0D);
[size=10.5000pt]    send_uart(0X0A);
[size=10.5000pt]}
[size=10.5000pt]/*******************清除TC35_RE缓存**********/
[size=10.5000pt]void ClrT35_re()
[size=10.5000pt]{
[size=10.5000pt]   uchar i;
[size=10.5000pt]   for(i=0;i<=TC35_MAX;i++)   TC35_RE=0;
[size=10.5000pt]   i_TC35_RECE=0;
[size=10.5000pt]   TC35_MAX=0;
[size=10.5000pt]
[size=10.5000pt]}
[size=10.5000pt]char find_str( char *str1, char *str2)
[size=10.5000pt]{[size=10.5000pt]        [size=10.5000pt]char index;
[size=10.5000pt]        char find_index;
[size=10.5000pt]        if( str1 == NULL || str2 == NULL)[size=10.5000pt]        [size=10.5000pt]{return 0;}
[size=10.5000pt]        else
[size=10.5000pt]   {    index = 0;
[size=10.5000pt]        while((*(str1 + index) )!= '\0')
[size=10.5000pt]     {
[size=10.5000pt]         find_index = 0;
[size=10.5000pt]         while(1)
[size=10.5000pt]       {
[size=10.5000pt]          if(*(str1 + index + find_index) == *(str2 + find_index))
[size=10.5000pt]          {
[size=10.5000pt]             if((*(str1 + index + find_index)=='\0')&&(*(str2 + find_index)=='\0'))  return 1;
[size=10.5000pt]              find_index++;
[size=10.5000pt]                             }
[size=10.5000pt]          else
[size=10.5000pt]          {
[size=10.5000pt]          if(*(str2 + find_index) == '\0')       return 1; //字符串比对完成返回1
[size=10.5000pt]                [size=10.5000pt]        [size=10.5000pt]else break;
[size=10.5000pt]          }
[size=10.5000pt]       }
[size=10.5000pt]                        index++;
[size=10.5000pt]     }
[size=10.5000pt]   }[size=10.5000pt]        [size=10.5000pt]        return 0;
[size=10.5000pt]}
[size=10.5000pt]/*****************ok应答**********************/
[size=10.5000pt]void TC35_ok()
[size=10.5000pt]{
[size=10.5000pt] delay(800);
[size=10.5000pt]   ClrT35_re();
[size=10.5000pt]}
[size=10.5000pt]/******************串口中断******************/
[size=10.5000pt]void serial() interrupt 4
[size=10.5000pt] {
[size=10.5000pt]     ES=0;
[size=10.5000pt]    if (RI)
[size=10.5000pt]      {
[size=10.5000pt]        RI = 0 ;
[size=10.5000pt]        i_receive=SBUF;
[size=10.5000pt]        TC35_RE[i_TC35_RECE++]=i_receive;
[size=10.5000pt]      if(i_TC35_RECE>TC35_MAX)
[size=10.5000pt]        {
[size=10.5000pt]         TC35_MAX=i_TC35_RECE;
[size=10.5000pt]         if(TC35_MAX>10) flag0=1;
[size=10.5000pt]         }
[size=10.5000pt]    }
[size=10.5000pt]     ES=1;
[size=10.5000pt]}
[size=10.5000pt]/*********************发送短信*********************/
[size=10.5000pt]void TX_SMS(uchar *cc,uchar *dd )
[size=10.5000pt]{
[size=10.5000pt]   send(at);
[size=10.5000pt]   TC35_ok();
[size=10.5000pt]   send(cmgf);
[size=10.5000pt]   TC35_ok();
[size=10.5000pt]   send(csca);
[size=10.5000pt]    TC35_ok();
[size=10.5000pt]   send(cmgs);
[size=10.5000pt]    delay(100);       //100ms
[size=10.5000pt]   send(cc);
[size=10.5000pt]    delay(100);
[size=10.5000pt]    send(dd);
[size=10.5000pt]    delay(100);
[size=10.5000pt]   send_uart(0x1A);
[size=10.5000pt]   send_uart(0x0D);      //回车键
[size=10.5000pt]   send_uart(0x0A);
[size=10.5000pt]    TC35_ok();
[size=10.5000pt]}
[size=10.5000pt]/*********************接收短信*********************/
[size=10.5000pt]
[size=10.5000pt]void  RE_SMS()
[size=10.5000pt]{   char k;
[size=10.5000pt]     if(flag0==1)
[size=10.5000pt]   {   delay(100);
[size=10.5000pt]      k=find_str(TC35_RE,cn);
[size=10.5000pt]      flag0=0;
[size=10.5000pt]      if((k==1))
[size=10.5000pt]      {
[size=10.5000pt]      ClrT35_re();
[size=10.5000pt]      k=0;
[size=10.5000pt]      flag1=1;
[size=10.5000pt]      }
[size=10.5000pt]   }
[size=10.5000pt]   if(flag1==1)
[size=10.5000pt]     {
[size=10.5000pt]      flag1=0;
[size=10.5000pt]      send(cmgr);
[size=10.5000pt]      delay(1500);
[size=10.5000pt]      if((TC35_RE[74]=='a'&&TC35_RE[75]=='9')||(TC35_RE[72]=='a'&&TC35_RE[73]=='9'))
[size=10.5000pt]                                                         { flag=1; send(cmgd); TC35_ok();}
[size=10.5000pt]       else {send(cmgd); TC35_ok();  delay(500); TX_SMS(cm,cm); delay(1000);
[size=10.5000pt] }
[size=10.5000pt]     }
[size=10.5000pt]     if(flag==1)
[size=10.5000pt]     {
[size=10.5000pt]       flag=0;
[size=10.5000pt]       delay(500);
[size=10.5000pt]        TX_SMS(cn,cn);
[size=10.5000pt]        delay(1000);
[size=10.5000pt]     }
[size=10.5000pt] }
[size=10.5000pt]
[size=10.5000pt]/*****************TC35初始化**********************/
[size=10.5000pt]void TC35_init()
[size=10.5000pt]{
[size=10.5000pt]   send(at);
[size=10.5000pt]   TC35_ok();
[size=10.5000pt]   send(cmgf);
[size=10.5000pt]   TC35_ok();
[size=10.5000pt]   send(cmgd);
[size=10.5000pt]   TC35_ok();
[size=10.5000pt]   send(cnmi);
[size=10.5000pt]   delay(400);
[size=10.5000pt]   TC35_ok();
[size=10.5000pt]   delay1ms(2000);
[size=10.5000pt]}
[size=10.5000pt]/********************主函数**********************/
[size=10.5000pt]
[size=10.5000pt] void main()
[size=10.5000pt] {
[size=10.5000pt]   lcdsendc(0x01);
[size=10.5000pt]   lcdinit();
[size=10.5000pt]   display(0x80,str);
[size=10.5000pt]   Init_DS18B20();
[size=10.5000pt]   uart_init();
[size=10.5000pt]    timer0_init();
[size=10.5000pt]   delay(1);
[size=10.5000pt]   TC35_init();
[size=10.5000pt]   TR0=1;
[size=10.5000pt]  lcdsendc(0x01);
[size=10.5000pt]  delay1ms(1);
[size=10.5000pt]  while(1)
[size=10.5000pt]  {
[size=10.5000pt]   if(flag2==1)
[size=10.5000pt]   {
[size=10.5000pt]    flag2=0;
[size=10.5000pt]    display(0x80,str3);
[size=10.5000pt]   display_yanwu();
[size=10.5000pt]   delay1ms(5);
[size=10.5000pt]   Read_Temperature();
[size=10.5000pt]   Temp2Str();
[size=10.5000pt]    display(0xc0,str2);
[size=10.5000pt]   display(0xc7,TempBuffer);
[size=10.5000pt]    delay1ms(5);
[size=10.5000pt]    }
[size=10.5000pt]    if(flag5==1){la_ba=0; TR0=0;TX_SMS(cm,cm);flag5=0; TR0=1;}
[size=10.5000pt]
[size=10.5000pt]   // RE_SMS();
[size=10.5000pt]  }
[size=10.5000pt] }
[size=10.5000pt]  void timer0() interrupt 1
[size=10.5000pt] {
[size=10.5000pt]     h++;
[size=10.5000pt]     TF0=0;
[size=10.5000pt]    TR0=0;
[size=10.5000pt]    TL0=0xb0;
[size=10.5000pt]    TH0=0x3c;
[size=10.5000pt]     if(h==40)
[size=10.5000pt]   { h=0;flag2=1;P0_0=1;}
[size=10.5000pt]      TR0=1;
[size=10.5000pt]  }

只有代码吗?看着也是晕了

谢谢分享谢谢分享

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top