| 
 
中级会员  
 
	积分454金钱454 注册时间2015-11-29在线时间50 小时 | 
 
 发表于 2016-4-14 23:02:39
|
显示全部楼层 
| [mw_shl_code=c,true]#include<reg51.h> //#include <REGX52.H>
 #include<string.h>
 #define uint unsigned int
 #define uchar unsigned char
 sbit LED0=P1^0;
 sbit LED1=P1^1;
 sbit LED2=P1^2;
 unsigned  char volatile temp[50]={0};
 unsigned  char volatile temp1[50]={0};
 unsigned  char volatile ju=0;
 unsigned  char volatile flag=0;
 unsigned  char  num[] = "ATD10086;\r";
 
 void delay1(int sec)
 {
 uint i, j= 0;
 for(i=0; i<sec; i++)
 {
 for(j=0; j<65535; j++);
 }
 }
 
 void init()
 {
 TMOD=0X20;
 TH1=0xfa;
 TL1=0xfa;
 TR1=1;
 REN=1;
 SM0=0;
 SM1=1;
 EA=1;
 ES=1;
 }
 
 void ser() interrupt 4
 {
 unsigned char i=0;
 if(RI==1)
 {
 RI=0;
 temp[ju]=SBUF;
 ju++;
 temp1=temp;
 temp=0;
 i++;
 
 
 
 }
 else if (ju>50)
 ju=0;
 }
 
 void sendchar(char *shuju)
 {
 while(*shuju!='\0')
 {
 ES=0;
 SBUF=*shuju;
 while(!TI);
 TI=0;
 shuju++;
 ES=1;
 }
 }
 void main()
 {
 LED0=1;
 LED1=1;
 LED2=1;
 init();
 
 sendchar("ati\r");
 LED0=0;
 delay1(1);
 LED0=1;
 delay1(1);
 LED0=0;
 delay1(1);
 LED0=1;
 delay1(1);
 
 LED0=0;
 LED1=0;
 delay1(5);
 /*
 while(1)
 {
 sendchar("AT+COPS?\r");
 LED1=0;
 delay1(1);
 LED1=1;
 while(flag==0);
 if(strstr(temp1,"CHINA MOBILE"))
 {
 break;
 }
 }           */
 //        while(1)
 {
 sendchar(num);
 LED0=1;
 LED1=1;
 delay1(5);
 LED0=0;
 LED1=0;
 delay1(5);
 while(1)
 {
 LED0=0;
 LED1=1;
 delay1(1);
 LED1=0;
 LED0=1;
 delay1(1);
 }
 }
 }[/mw_shl_code]
 | 
 |