Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed TextLCD TinyGPS TinyGPSplus
main.cpp
00001 #include "mbed.h" 00002 #include "Serial.h" 00003 #include "TinyGPSplus.h" 00004 #include "TextLCD.h" 00005 00006 00007 Serial gps(p9, p10); // tx, rx 00008 Serial pc(USBTX, USBRX); // tx, rx 00009 DigitalOut myled(LED1); 00010 Serial xbee(p13,p14); 00011 TinyGPSPlus tgps; 00012 AnalogIn vo(p20); 00013 AnalogIn vi(p16); 00014 TextLCD lcd(p24,p26,p27,p28,p29,p30); 00015 00016 bool read_gps(bool debug=false) { 00017 char ch; 00018 bool stat; 00019 if(gps.readable()) { 00020 ch = gps.getc(); 00021 if(debug)pc.putc(ch); 00022 stat = tgps.encode(ch); 00023 } 00024 return stat; 00025 } 00026 00027 int main() 00028 { 00029 int hour, time; 00030 xbee.baud(9600); 00031 lcd.cls(); 00032 while(1){ 00033 if(read_gps() && tgps.time.second()%5 == 0){ 00034 if(tgps.time.hour()>15){ 00035 hour=tgps.time.hour()%15; 00036 }else{ 00037 hour=tgps.time.hour()+9; 00038 } 00039 if(time != tgps.time.second()){ 00040 xbee.printf("%d/%d/%d, %d:%d:%d ,",tgps.date.year(),tgps.date.month(),tgps.date.day(),hour,tgps.time.minute(),tgps.time.second()); 00041 xbee.printf("%f, %f ,",tgps.location.lat(),tgps.location.lng()); 00042 xbee.printf("%f\r\n",vo.read()*3.3*0.3); 00043 lcd.locate(0,0); 00044 lcd.printf("%f",vo.read()*3.3*0.3); 00045 time=tgps.time.second(); 00046 } 00047 } 00048 } 00049 } 00050
Generated on Mon Jul 25 2022 04:34:40 by
1.7.2