用个8位单片机+sim900a+gps模块自制建议定位装置 (8位单片机能做出什么产品?)
整理分享用个8位单片机+sim900a+gps模块自制建议定位装置 (8位单片机能做出什么产品?),希望有所帮助,仅作参考,欢迎阅读内容。
内容相关其他词:单片机八位,8位单片机8位指什么,8位单片机是 为8位,8位单片机应用,8位单片机应用,单片机八位,8位单片机应用,8位单片机能做出什么产品?,内容如对您有帮助,希望把内容链接给更多的朋友!
然后对GPSshield扩展板*作,开关拨到5V,跳线帽按照RXD->D1,TXD->D0如图连接,接上GPS天线 最后按照顺序把三个家伙给堆起来 在编译程序之前我们需要下载arduino的g*和gps的支持库,解压后放在Arduino\libraries的目录下 下面是程序代码*粘帖过去IDE中,编译好后下载到arduino中就好了。#include"SIM.h"#include//#include"inetGSM.h"#include"*s.h"//#include"call.h"#include#include/*ThissamplecodedemonstratesthenormaluseofaTinyGPSobject.ItrequirestheuseofSoftwareSerial,andassumesthatyouhavea-baudserialGPSdevicehookeduponpins3(rx)and4(tx).*/TinyGPSgps;#defineledpin#definepwrkey//**************************************************************************char*s_rx[];//ReceivedtextSMSbytetype_*s=SMS_ALL;//TypeofSMSbytedel_*s=1;//0:Nodeleting*s-1:DeletingSMScharnumber_incoming[];//**************************************************************************SMSGSM*s;interror;booleanstarted=false;boolnewData=false;chargps_year[8];chargps_mon[3];chargps_day[3];chargps_hour[3];chargps_min[3];chargps_sec[3];chargps_lon[];chargps_lat[];chargps_*s[];voidsetup(){//softwarepowersimuppinMode(pwrkey,OUTPUT);digitalWrite(pwrkey,HIGH);delay();digitalWrite(pwrkey,LOW);Serial.begin();Serial2.begin();if(g*.begin()){Serial.println("\nstatus=READY");g*.forceON();//ToensurethatSIMisnotonlyinchargemodestarted=true;}elseSerial.println("\nstatus=IDLE");if(started){//deleteall**essageSerial.println("DeletingSMS");charerror=DeleteAllSMS();if(error==1)Serial.println("AllSMSdeleted");elseSerial.println("SMSnotdeleted");}else{Serial.println("SIMNOTEX*TED");while(1);}delay();}voidloop(){if(started){check_gps();Check_SMS();}}voidCheck_SMS()//Checkifthereisan*s'type_*s'{charpos_*s_rx;//ReceivedSMSpositionpos_*s_rx=*s.IsSMSPresent(type_*s);if(pos_*s_rx!=0){//Readtext/number/positionof*s*s.GetSMS(pos_*s_rx,number_incoming,*s_rx,);Serial.print("ReceivedSMSfrom");Serial.print(number_incoming);Serial.print("(simposition:");Serial.print(word(pos_*s_rx));Serial.println(")");Serial.println(*s_rx);if(del_*s==1)//If'del_*s'is1,idelete*s{error=*s.DeleteSMS(pos_*s_rx);if(error==1)Serial.println("SMSdeleted");elseSerial.println("SMSnotdeleted");}if((strstr(*s_rx,"gps")!=0)&&(strlen(*s_rx)==3)){Serial.println("\nsendingSMS");if(newData){if(*s.SendSMS(number_incoming,gps_*s))Serial.println("\nSMSsentOK");elseSerial.println("\nSMSsenterror");}else{if(*s.SendSMS(number_incoming,"gpsnotready"))Serial.println("\nSMSsentOK");elseSerial.println("\nSMSsenterror");}}Serial2.flush();}newData=false;return;}charcheck_gps(){newData=false;unsignedlongchars;unsignedshortsentences,failed;//ForonesecondweparseGPSdataandreportsomekeyvaluesfor(unsignedlongstart=millis();millis()-start<;){while(Serial2.available()){charc=Serial2.read();//Serial.write(c);//uncommentthislineifyouwanttoseetheGPSdataflowingif(gps.encode(c))//Didanewvalidsentencecomein?newData=true;}}if(newData){floatflat,flon;unsignedlongage;int_year;byte_month,_day,_hour,_minute,_second,_hundredths;gps.f_get_position(&flat,&flon,&age);gps.crack_datetime(&_year,&_month,&_day,&_hour,&_minute,&_second,&_hundredths,&age);flat==TinyGPS::GPS_INVALID_F_ANGLE?0.0:flat,6;flon==TinyGPS::GPS_INVALID_F_ANGLE?0.0:flon,6;dtostrf(flat,,6,gps_lat);dtostrf(flon,,6,gps_lon);strcpy(gps_*s,"lat:");strcat(gps_*s,gps_lat);strcat(gps_*s,"\n");strcat(gps_*s,"lon:");strcat(gps_*s,gps_lon);strcat(gps_*s,"\n");strcat(gps_*s,"time:");itoa(_year,gps_year,);strcat(gps_*s,gps_year);itoa(_month,gps_mon,);if(strlen(gps_mon)==1)strcat(gps_*s,"0");strcat(gps_*s,gps_mon);itoa(_day,gps_day,);if(strlen(gps_day)==1)strcat(gps_*s,"0");strcat(gps_*s,gps_day);itoa(_hour,gps_hour,);if(strlen(gps_hour)==1)strcat(gps_*s,"0");strcat(gps_*s,gps_hour);itoa(_minute,gps_min,);if(strlen(gps_min)==1)strcat(gps_*s,"0");strcat(gps_*s,gps_min);itoa(_second,gps_sec,);if(strlen(gps_sec)==1)strcat(gps_*s,"0");strcat(gps_*s,gps_sec);Serial.println(gps_*s);}}charDeleteAllSMS(){charret_val=-1;if(CLS_FREE!=g*.GetCommLineStatus())return(ret_val);g*.SetCommLineStatus(CLS_ATCMD);ret_val=0;//stillnotpresentg*.SimpleWriteln(F("AT+CMGDA=\"DELALL\""));switch(g*.WaitResp(,,"OK")){ 通过9v电池供电或者是充电宝u*供电,把做好的三层不明物体放在开阔的地方,想arduino的*号码发送“gps”*,之后会收到一个回信,内容为 lat:. lon:. time: lat表示纬度,lon表示经度,time表示时间,不过是“格林尼治时间”(本初子午线)不是北京时间,和北京时间相差8小时。不会算的回去学地理。如果你收到“gpsnotready”回信,那就是说明没有搜到gps卫星,等一下或者是换个地方。