#include #define uchar unsigned char #define uint unsigned int sbit s1=P3^3; sbit s2=P3^4; sbit s3=P3^5; uchar code at[] = "AT\r"; uchar code call[] = "ATD15818108549;\r"; uchar code cmgf[] = "AT+CMGF=0\r"; uchar code size1[] = "AT+CMGS=39\r"; uchar code size2[] = "AT+CMGS=31\r"; uchar code mesi1[] = "0891683108200005F011000D91685118188045F90008AA188B66544AFF1A67094EBA8FDB516576D189C6830356F4FF01\x01a\r"; //uchar code mesi1[] = "0891683108200005F011000D91685118188045F90008AA188B66544AFF1A67094EBA8FDB516576D189C6830356F4FF01\x01a "; uchar code mesi2[] = "0891683108200005F011000D91685118188045F90008AA108B66544AFF1A71646C146CC46F0FFF01\x01a\r"; /*********************************************************** 函数名称:Ini_UART 函数功能:串口初始化设置 入口参数:无 出口参数:无 ***********************************************************/ void uart_int(void) { SCON = 0x50; //UART方式1:8位UART; REN=1:允许接收 PCON = 0x00; //SMOD=0:波特率不加倍 TMOD = 0x20; //T1方式2,用于UART波特率 TH1 = 0xFD; TL1 = 0xFD; //UART波特率设置:9600 TR1 = 1; // EA=1; // ES=1; } void delay(uint z) { uint x,y; for(x=z;x0;x--)for(y=110;y0;y--); } void send(uchar *tab) { while((*tab)!= '\0') { SBUF =*tab; while(TI ==0); TI = 0; tab++; } } void main() { uart_int(); send(at); delay(150); send(cmgf); delay(150); while(1) { if(s1==0) { delay(10); if(s1==0) { while(!s1); P1=0xf0; // send(at); delay(400); send(cmgf); delay(400); send(size1); delay(400); send(mesi1); P1=0x0f; } } if(s2==0) { delay(10); if(s2==0) { while(!s2); P1=0xf0; // send(at); delay(350); send(cmgf); delay(350); send(size2); delay(350); send(mesi2); P1=0x0f; } } if(s3==0) { delay(10); if(s3==0) { while(!s3); P1=0xf0; // send(at); delay(200); send(cmgf); delay(200); send(call); P1=0x0f; } } } }
是不是发不完呀 我邮箱897708713@qq.com 谢谢!
学习
这么难吗?
学习
看看
学习