Mengawinkan gps em 411 dengan Arduino UNO Blog Adi Sanjaya Global Techno Solution - AS-GTS

Mengawinkan gps em 411 dengan Arduino UNO Blog Adi Sanjaya Global Techno Solution - AS-GTS

Size
Price:

Read more

    berikut ini adalah source code untuk menampilka lattitide - longitude dsb dengan menggunakan  gps em 411 + Arduino Uno
    #include <string.h>
    #include <ctype.h>
    #include <LiquidCrystal.h>
     int ledPin1= 10; // LED test pin
     int ledPin2= 9; //LED warning limit
     int ledPin3= 8; //LED warning over limit
     int rxPin = 0;                    // RX PIN
     int txPin = 1;                    // TX TX
     int rx_val =0 ;
     int byteGPS=-1;
     char linea[300] = "";
     char comandoGPR[7] = "$GPRMC";
     int cont=0;
     int bien=0;
     int conta=0;
     int indices[13];
     LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
     void setup() {
       pinMode(10,OUTPUT);       // Initialize LED pin
       pinMode(9, OUTPUT);
       pinMode(8, OUTPUT);
       pinMode(rxPin, INPUT);
       pinMode(txPin, OUTPUT);
       lcd.begin(16,2);
       lcd.setCursor(0,0);
       lcd.print("Lat:");
      //lcd.setCursor(0,1);
      //lcd.print("Long:");
       Serial.begin(4800);
       for (int i=0;i<300;i++){       // Initialize a buffer for received data
         linea[i]=' ';
       }  
     }
     void loop() {
       digitalWrite(10,HIGH); //indikator  runing data reciver
       byteGPS=Serial.read();    // Read a byte of the serial port
       //lcd.write(Serial.read()); // TAMBAHAN
       if (byteGPS == -1) {           // See if the port is empty yet
         delay(100);
       } else {
         // note: there is a potential buffer overflow here!
         linea[conta]=byteGPS;        // If there is serial port data, it is put in the buffer
         conta++;                      
         Serial.write(byteGPS);
         
         if (byteGPS==13){            // If the received byte is = to 13, end of transmission
           // note: the actual end of transmission is <CR><LF> (i.e. 0x13 0x10)
           digitalWrite(10, LOW);
           cont=0;
           bien=0;
           // The following for loop starts at 1, because this code is clowny and the first byte is the <LF> (0x10) from the previous transmission.
           for (int i=1;i<7;i++){     // Verifies if the received command starts with $GPR
             if (linea[i]==comandoGPR[i-1]){
               bien++;
             }
           }
         
           if(bien==6){               // If yes, continue and process the data
             for (int i=0;i<300;i++){
               if (linea[i]==','){    // check for the position of the  "," separator
                 // note: again, there is a potential buffer overflow here!
                 indices[cont]=i;
                 cont++;
               }
               if (linea[i]=='*'){    // ... and the "*"
                 indices[12]=i;
                 cont++;
               }
             }
             Serial.println("");      // ... and write to the serial port
             Serial.println("");
             Serial.println("---------------");
             for (int i=0;i<12;i++){
               switch(i){
                 
                 case 0 :Serial.print("Time in UTC (HhMmSs): "); break;
                 case 1 :Serial.print("Status (A=OK,V=KO): ");break;
                 case 2 :Serial.print("Latitude: ");break;
                 case 3 :Serial.print("Direction (N/S): ");break;
                 case 4 :Serial.print("Longitude: ");break;
                 case 5 :Serial.print("Direction (E/W): ");break;
                 case 6 :Serial.print("Velocity in knots: ");break;
                 case 7 :Serial.print("Heading in degrees: ");break;
                 case 8 :Serial.print("Date UTC (DdMmAa): ");break;
                 case 9 :Serial.print("Magnetic degrees: ");break;
                 case 10 :Serial.print("(E/W): ");break;
                 case 11 :Serial.print("Mode: ");break;
                 case 12 :Serial.print("Checksum: ");break;
               }
              for (int j=indices[i];j<(indices[i+1]-1);j++){
                 Serial.print(linea[j+1]);                
                 lcd.print(linea[j+15]);
                 delay(0);
                 
               // lcd.setCursor(5,1);   // set cursor valLong :                          
               //  lcd.print(linea[j+35]);
               //  delay(0);
                         
                if (linea[j+21]>4 ){
                 digitalWrite(9, HIGH); //indikator warning limit
                 }else{
                 digitalWrite(9, LOW);
                // delay(100);
               
                 if (linea[j+21]>9 ){
                 digitalWrite(8, HIGH); //indikator over limit
                 }else{
                 digitalWrite(8, LOW);
                // delay(100);
               
                 }
                   }
       
               }
               
               Serial.println("");
             }
             Serial.println("---------------");
           }
           conta=0;                    // Reset the buffer
           for (int i=0;i<300;i++){    //  
             linea[i]=' ';            
           }                
         }
       }
               lcd.setCursor(4,0); // set cursor val Lat :  
               
     }
     Bagian ini berfungsi untuk menampilkan data lattitude pada LCD yang terkoneksi ke arduino
     lcd.print(linea[j+15]);
    Berikut serial monitor nya :

    $GPGGA,073732.000,0055.2030,N,10430.8336,E,1,09,0.9,38.7,M,8.5,M,,0000*56
    $GPGSA,A,3,12,05,06,02,17,25,10,26,15,,,,2.0,0.9,1.9*33
    $GPRMC,073732.000,A,0055.2030,N,10430.8336,E,0.34,359.26,081014,,,A*65

    ---------------
    Time in UTC (HhMmSs): 073732.000
    Status (A=OK,V=KO): A
    Latitude: 0055.2030
    Direction (N/S): N
    Longitude: 10430.8336
    Direction (E/W): E
    Velocity in knots: 0.34
    Heading in degrees: 359.26
    Date UTC (DdMmAa): 081014
    Magnetic degrees:
    (E/W):
    Mode: A
    ---------------

    $GPGGA,073733.000,0055.2031,N,10430.8336,E,1,09,0.9,38.7,M,8.5,M,,0000*56
    $GPGSA,A,3,12,05,06,02,17,25,10,26,15,,,,2.0,0.9,1.9*33
    $GPRMC,073733.000,A,0055.2031,N,10430.8336,E,0.25,344.02,081014,,,A*6F

    ---------------
    Time in UTC (HhMmSs): 073733.000
    Status (A=OK,V=KO): A
    Latitude: 0055.2031
    Direction (N/S): N
    Longitude: 10430.8336
    Direction (E/W): E
    Velocity in knots: 0.25
    Heading in degrees: 344.02
    Date UTC (DdMmAa): 081014
    Magnetic degrees:
    (E/W):
    Mode: A
    ---------------




     
    Contact Person : Taufik Adi Sanjaya
    No HP / Whats App : 0823 2613 3990
    PIN BBM 5983E244
    Alamat : Jalan Imogiri Timur KM 11, 
    Blawong 1 , RT 01, Trimulyo, 

    Jetis, Bantul 55781.
    Anda membutuhkan komponen elektronik , Arduino, Sensor, Tutorial(paket belajar), jasa pembuatan alat berbasis mikrokontroler, kendali lampu via jaringan LAN, dan sebagainya ? anda dapat membelinya di www.kedaiarduino.com
     www.kedaiarduino.com

4 Reviews

  1. Replies
    1. jelas bisa lah,ke PC bisa ke LCD 2x16 juga bisa

      Delete
  2. Maaf mas saya udah coba programya dan bisa tapi saya ga begitu ngerti secara detail,,mohon penjelasanya?

    ReplyDelete
  3. Some way or another seafarers identify with this kind of marine GPS frameworks since they discover some solace in listening to a "human" voice; however it might be a PC created one. With respect to the radar-situated GPS frameworks, they just radiate a beep as a type of sign. https://www.engadget.com/2016/09/23/what-does-gps-actually-do-other-than-tracking/

    ReplyDelete

Silakan dikomentari

Contact form

Name

Email *

Message *