|
發(fā)一個(gè)SIM900A+GPS單片機(jī)源程序
QQ截圖20180202014738.jpg (43.84 KB, 下載次數(shù): 31)
下載附件
2018-2-2 01:46 上傳
單片機(jī)源程序如下:
- /**************************************************************************
- * *
- * GPS+GPRS方式實(shí)現(xiàn)GPS地理位置信息通過GPRS無線上網(wǎng)方式傳給上位機(jī)實(shí)例程序 *
- * *
- * 功能:GPS地理坐標(biāo)、衛(wèi)星時(shí)間等信息通過GPRS方式傳到上位機(jī) *
- * 板上提供Nokia5110液晶屏接口,GPS信息可以通過液晶實(shí)時(shí)顯示 *
- * 版本: V1.0 (08/24) *
- *【聲明】此程序僅用于學(xué)習(xí)與參考,引用請(qǐng)注明版權(quán)和作者信息! *
- * *
- *************************************************************************/
- #include <SIM300.h>
- #include <reg51.h>
- #include <string.h>
- #include <gps.h>
- void dis_time()
- {
- unsigned char hh;
- unsigned char i,temp_buff[10];
- hh=(gps_time[0]-'0')*10+(gps_time[1]-'0');
- hh+=8; //將格林威治時(shí)間校正成北京時(shí)間
- if(hh>=24)
- hh-=24; //校正小時(shí)
- temp_buff[0]=hh/10+'0';
- temp_buff[1]=hh%10+'0';
- temp_buff[2]=':';
- temp_buff[3]=gps_time[2];
- temp_buff[4]=gps_time[3];
- temp_buff[5]=':';
- temp_buff[6]=gps_time[4];
- temp_buff[7]=gps_time[5];
- for(i=0;i<8;i++)
- gps_time[i]=temp_buff[i];
- LCD_write_english_string(0,0,"TIME");
- LCD_set_XY(36,0);
- for(i=0;i<8;i++)
- {
- LCD_write_char(gps_time[i]);
- }
- }
- void dis_jwdu()
- {
- unsigned i;
- LCD_set_XY(0,1);LCD_write_char(gps_latitude_dir);
- LCD_set_XY(24,1);
- for(i=0;i<10;i++)
- {
- LCD_write_char(gps_latitude[i]);
- }
- LCD_set_XY(0,2);LCD_write_char(gps_longitude_dir);
- LCD_set_XY(30,2);
- for(i=0;i<9;i++)
- {
- LCD_write_char(gps_longitude[i]);
- }
- }
- void dis_high()
- {
- unsigned i;
- LCD_write_english_string(0,5,"HIGH");
- LCD_set_XY(42,5);
- for(i=0;i<7;i++)
- {
- LCD_write_char(gps_height[i]);
- }
- }
- /*gprs_data()
- {
- unsigned char buff[40];
- unsigned i;
-
- }*/
- //聲明GPS驅(qū)動(dòng)部分的全局變量
- void delay_time(unsigned char t)
- {
- unsigned int i,n;
- for(n=0;n<t;n++)
- for(i=0;i<10000;i++);
- }
- void main(void)
- {
- LCD_init(); //LCD初始化
- LCD_write_english_string(0,0,"System Starting and Initializing......");
- Delay_ms(5000);
- sys_init(); //UART1初始化
- Init_GPS_module(); //GPS初始化
- Start_GSM(); //開啟模塊
- GSM_init(); //GSM初始化
- BELL_UP(); //BEEP
- clear_SystemBuf(); //清除串口1緩沖區(qū)數(shù)據(jù)
- while(strsearch("Call Ready",SystemBuf)==0);//等待模塊準(zhǔn)備好
- BELL_UP();
- do
- {
- LCD_clear();
- clear_SystemBuf();
- sendstring(AT_COPS);
- LCD_write_english_string( 4,2,"searching>");
- Delay_ms(3000);
- LCD_write_english_string( 4,2,"searching->");
- Delay_ms(3000);
- LCD_write_english_string( 4,2,"searching-->");
- Delay_ms(3000);
- LCD_write_english_string( 4,2,"searching--->");
- Delay_ms(3000);
- }while((strsearch("CHINA UN",SystemBuf)==0)&&(strsearch("CHINA MOBILE",SystemBuf)==0));//檢測服務(wù)商信息
- BELL_UP();
- LCD_clear();
- LCD_write_english_string(0,0,"KinCony");
- //GPRS初始化 */
- ES=0;
- Delay_ms(10000);
- Delay_ms(10000);
- sendstring(AT_CIPMUX);
- Delay_ms(10000);
- sendstring(AT_CIPSTART);
- //while(strsearch("CONNECT OK",SystemBuf)!=0);
- BELL_UP();
- LCD_clear(); //清屏幕
- ET0=1; //開中斷
- while(1)
- {
- if(gps_data_ok_flag) //查詢GPS數(shù)據(jù)是否OK
- {
- IE2=0x00; //如果OK就關(guān)中斷處理數(shù)據(jù)并顯示數(shù)據(jù)
- dis_time();
- dis_jwdu();
- dis_high();
- gps_data_ok_flag=0;
- IE2=0x01;
- }
- }
- }
- /********************************************************************************************************
- ** 函數(shù)名稱 Int_Timer0()
- ** 函數(shù)功能 定時(shí)器中斷位,是整個(gè)程序的心跳,如果停止,程序會(huì)死機(jī)
- *********************************************************************************************************/
- void Int_Timer0(void) interrupt 1 using 3
- {
- unsigned char i;
- TH0 = 0xB8;
- TL0 = 0x00; //20ms的時(shí)鐘基準(zhǔn)
- timer_1S_cnt++;
- timercount++;
- EA=0;
- if(timer_1S_cnt==50) //20×50=1000M
- {
- timer_10S_cnt++;
- timer_1S_cnt=0;
- timer_S_cnt++;
- } //1秒=1000毫秒
- if(timer_10S_cnt==10) //10S
- {
- timer_10S_cnt=0;
- BELL_UP();
- sendstring(AT_CIPSEND);
- Delay_ms(5000);
- Delay_ms(5000);
- for(i=0;i<8;i++)
- {
- sendchar(gps_time[i]);
- ……………………
- …………限于本文篇幅 余下代碼請(qǐng)從51黑下載附件…………
復(fù)制代碼
所有資料51hei提供下載:
SIM900 GPRS GPS單片機(jī)源程序_帶NOKIA5110顯示.zip
(77.26 KB, 下載次數(shù): 69)
2018-2-2 01:44 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
|
評(píng)分
-
查看全部評(píng)分
|