Joke Collection Website - Public benefit messages - Short Message Receiving and Sending System Based on Single Chip Microcomputer
Short Message Receiving and Sending System Based on Single Chip Microcomputer
# include & ltreg52.h & gt
# Define uchar unsigned characters
# Define uint unsigned integer
void GSM _ UART();
unsigned int UART _ delay(unsigned int z);
void GSM _ init();
void GSM _ CMGF();
void GSM _ ATC MGS();
void TELNUM();
void GSM _ TEXT();
void GSM _ test();
void BUTTON();
Unsigned integer d;
Unsigned character code ATEnter[]={0x4 1, 0x54, 0x0d };;
Unsigned character code atcmgcenter [] = {0x41,0x54, 0x2b, 0x43, 0x4d, 0x47, 0x46, 0x3d, 0x3 1, 0x0d };;
Unsigned character code ATCMGS[]={0x4 1, 0x54, 0x2b, 0x43, 0x4d, 0x47, 0x53, 0x3d };;
Unsigned char code TEL_NUM[]={0x30, 0x3 1, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39};
Unsigned character code text []={0x4b, 0x4f };;
Unsigned character code Enter[]= {0x0d };;
Unsigned character code oneA[]={0x3 1, 0x41};
Unsigned character idatabuf [20];
Int mark;
int buf num = 0;
uchar str 1[]= { " AT " };
uchar str 2[]= { " ATD " };
uchar str 3[]= { " ATH " };
uchar str 5[]= { " AT+CMGS = " };
sbit bell=p 1^6;
sbit betton 1_ 1=p3^3;
sbit betton 1=p3^4;
void gsm_uart()
{ EA = 1;
ES = 1;
SCON = 0x 50; //UART mode 1:8-bit UART; REN= 1: receiving is allowed.
PCON = 0x 00; //SMOD=0: The baud rate is not doubled.
TMOD = 0x 20; //T 1Mode 2, used for UART baud rate.
th 1 = 0x FD;
TL 1 = 0x FD; //UART baud rate setting: 9600
TI = 0;
RI = 0;
EA = 1;
tr 1 = 1;
}
Unsigned integer uart_delay (unsigned integer z)
{unsigned integers a, b;
for(a = z; a & gt0; Answer-)
{ for(b = 1000; b & gt0; b-); }
Return z;
}
Use 3 to invalidate ddd () interrupt 4.
{
If(RI) // handles the reception interrupt.
{ buf[buf num]= SBUF; //receive serial data
RI = 0;
buf num++; //Clear the interrupt flag bit
}
}
void GSM_init()
{
uint I;
Uchar code test []= {0x4 1, 0x54, 0x0d };;
ES = 0;
for(I = 0; I<3; i++)
{
SBUF = test[I];
while(TI = = 0);
TI = 0;
}
ES = 1;
}
void GSM_CMGF()
{
Uchar code sel[ 10]= {0x4 1, 0x54, 0x2B, 0x43, 0x4D, 0x47, 0x46, 0x3D, 0x3 1, 0x0d };; //AT+CMGF= 1 enter
uint I;
for(I = 0; I< 10; i++)
{
SBUF = sel[I];
while(TI = = 0);
TI = 0;
}
}
void GSM_ATCMGS()
{ uint I;
Uchar code tel[20]= {0x4 1, 0x54, 0x2B, 0x43, 0x4D, 0x47, 0x53, 0x3D, 0x3 1, 0x33, 0x38, 0x33,
0x36,0x30,0x32,0x33,0x33,0x37,0x39,0x0d };
for(I = 0; I & lt20; i++)
{
SBUF = tel[I];
while(TI = = 0);
TI = 0;
}
}
void GSM_TEXT()
{
Uchar code neirong[ 10]={0x48, 0x69, 0x2 1, 0x6E, 0x69, 0x68, 0x6 1, 0x6F, 0x2E, 0x1a}; //Hi! Ni Hao.
uint I;
ES = 0;
for(I = 0; I< 10; i++)
{
SBUF = nei Rong[I];
while(TI = = 0);
TI = 0;
}
ES = 1;
}
Void send ()
{
SBUF = oneA[0]; while(TI = = 0); TI = 0;
SBUF = oneA[ 1]; while(TI = = 0); TI = 0;
}
void GSM_test()
{
GSM _ UART();
UART _ delay(400);
GSM _ init();
UART _ delay( 1000);
ES = 0;
buf num = 0;
if(buf[5]= = ' O ' & amp; & ampbuf[6] =='K ')
{
P0 = 0xfeUART _ delay( 1000); P0 = 0xff
}
other
{
P0 = 0x00UART _ delay(4000); P0 = 0xff
}
}
Invalid button ()
{ betton 1 = 1;
betton 1 _ 1 = 0;
if(betton 1==0)
{
GSM _ test();
UART _ delay( 1200);
GSM _ CMGF();
UART _ delay( 1200);
GSM _ ATC MGS();
UART _ delay( 1200);
GSM _ TEXT();
UART _ delay(800);
UART _ delay(500);
betton 1 = 1;
}
}
Master ()
{
BUTTON();
UART _ delay( 10);
}
- Previous article:SMS bombing is illegal.
- Next article:This kind of confession, the reply is, I am honored and happy. What is it?
- Related articles
- How to check the number of SMS center
- Can I get a refund if I haven't picked up the car after paying the full price?
- What should I do if Mi You Institute of Intelligent Verification Code network times out?
- How dare a thief not tell the police?
- The woman received 1 oven and was cheated 1.4 million. How to improve the anti-fraud consciousness in life?
- Can Jiangsu CCB still handle free SMS reminders for senior citizens?
- Samsung SMS font size
- Apple 6splus has a white screen, a black screen and a blue channel.
- Collect the words 1000 in the annual work plan of the bank.
- How to open Zhang Le Wealth Connect New Debt?