51 MCU is a general term for all MCUs compatible with Intel 8031 ​​instruction system. The first ancestor of this series of MCUs is Intel's 8004 MCU. Later, with the development of Flash rom technology, the 8004 MCU has made great progress and become one of the most widely used 8-bit MCUs. Its representative model is ATMEL's AT89 series. Widely used in industrial measurement and control systems. Many companies have launched 51 series compatible models, which will occupy a large number of markets for a long time to come. 51 single-chip microcomputer is a single-chip computer that is the basic introduction, or the most widely used one. It should be noted that the 51 series of single-chip microcomputers generally do not have self-programming capabilities. The SIM900A module is a compact GSM/GPRS module with SMT package, STE-based single-chip case, ARM926EJ-S architecture, powerful performance and built-in client application. Can be widely used in vehicle tracking, fleet management, wireless POS, handheld PDA, smart meter reading and power monitoring and many other directions. After the program runs, if the gprs module finds the service provider signal, it will dial the specified number. 1. Connect the serial port 1 of your 51 MCU to the tx rx gnd of GSM. 2. Find the #define in the front of the program, modify your own microcontroller configuration according to the instructions, compile the program. 3. Download the program 4. Press the module reset button to start the module, wait for the signal light to flash slowly, reset the microcontroller 4. Wait for the transmission to succeed #include 《REGX52.H》 #define uchar unsigned char #define uint unsigned int //The following is the configuration of the LED on the board, and change Px_x to its corresponding foot. #define LED1_ON P1_0 = 0 #define LED1_OFF P1_0 = 1 #define LED2_ON P1_1 = 0 #define LED2_OFF P1_1 = 1 #define LED3_ON P1_2 = 0 #define LED3_OFF P1_2 = 1 #define LED4_ON P1_3 = 0 #define LED4_OFF P1_3 = 1 //The following is the crystal size of your 51 MCU #define FOSC_110592M //#define FOSC_12M //The following is the content sent to the phone after booting, and the sent number is modified in the program. Uchar sms_text[] = "123"; / / Note that whether the signal is received or sent, it will enter the interrupt service program / * Initialization program (must be used, otherwise it can not send and receive), the secondary program will use the timer 1 * / Void SerialInTI()//Initializer (must be used, otherwise it cannot be sent or received) { TMOD=0x20; // Timer 1 operation mode 2: 8-bit auto-reload timer #ifdef FOSC_12M //In this case, initialize the serial port according to the different values ​​of the crystal oscillator size. TH1=0xf3;//Load initial value, baud rate 2400 TL1=0xf3; #else TH1=0xfd; / / load initial value, baud rate 9600 TL1=0xfd; #endif //end of SOC_12M TR1=1; / / open the timer SM0=0;//Set the serial communication working mode, (10 is a part of transmission, the baud rate is variable, controlled by the overflow rate of timer 1) SM1=1;//(same as above) In this mode, the timer overflows and sends a bit of data. REN=1; / / serial receive enable bit (to set sm0sm1 and then open serial allow) EA=1; / / open total interruption ES=1; / / open serial port interrupt } / * Serial communication interrupt, the completion of transmission and reception will enter the interrupt * / Void Serial_interrupt() interrupt 4 { // a=SBUF; P2=SBUF; RI=0; / / receiving interrupt signal clear, indicating that it will continue to receive //flag=1;//Enter the interrupted glyph } Void Uart1Send(uchar c) { SBUF=c; While(!TI);//waiting to send completion signal (TI=1) TI=0; } / / serial port continuously send char array, encounter termination number / 0 will stop Void Uart1Sends(uchar *str) { While(*str!='\0') { SBUF=*str; While(!TI);//waiting to send completion signal (TI=1) TI=0; Str++; } } //The delay function is about 1s clock, but the delay is not allowed. . . Void DelaySec(int sec) { Uint i , j= 0; For(i=0; i"sec; i++) { For(j=0; j“65535; j++) { } } } Void main() { Uchar i = 0; LED1_OFF; LED2_OFF; LED3_OFF; LED4_OFF; SerialInti(); While(1) { LED1_ON; LED2_OFF; Uart1Sends ("AT+CMGF=1"); DelaySec(3);//delay 3 seconds Uart1Sends ("AT+CSCS=\"GSM\")); DelaySec(3);//delay 3 seconds Uart1Sends ("AT+CSMP=17,167,0,250");//Device SMS mode (mobile phone auto save mode) // Uart1Sends ("AT+CSMP=17,167,0,240");//Device SMS mode (mobile phone non-automatic save mode) DelaySec(3);//delay 3 seconds Uart1Sends("AT+CMGS=\"18332563682\")); DelaySec(5);//delay 3 seconds Uart1Sends(sms_text); Uart1Send(0x1a); LED2_ON; LED1_OFF; DelaySec(15);//delay 20 seconds } } 15W Interchangeable Power Adapter 15W Interchangeable Power Adapter,24V0.5A Ac/Dc Power Adapter,Detachable Ac-Dc Power Adapter 15W,5V 2A Interchangeable Plug Power Adapter Guangdong Mingxin Power Technologies Co.,Ltd. , https://www.mxpowersupply.com