Wednesday, 15 February 2012

c++ - Testing arduino gps -


A friend of mine and me are building a robot in which GPS for arduino is to check the GPS we have the following Circuit built:

Arduino circuit

We have GPS Trying the following code to check:

  #include & software ;; serial.h> #include & lt; TinyGPS.h & gt; Long latitude, lan; // Create variables for latitude and longitude object software; GPSSial (2, 3); // TinyGPS GPS making GPS sensor connection; // Create a GPS object zero setup () {Serial.begin (9600); // Serial GPS Serial. Busin (4800); // connect GPS sensor} zero loop () {serial. Print ("test"); // I did implement this test while (GPSSearial .Unavailable ()) {// Check GPS Data Serial Print ("test2"); // I have implemented this test if (GPS. Encoded (GPSSearial read ()) // // GPS data serial Print ("Test 3"); // I GPS this test Gate_position (& amp; latitude & loan) applied; // Get Latitude and Longitude // Display Status Serial. Print ("Status:"); Serial. Print ("Lat:"); Serial.print (latitude); Serial.print (""); // print latitude serial Print ("lawn:"); Serial.printeline (loan); // print longitude}}}  

The thing is that serial monitor produces output test number 1, but test number 2 and no3 do not output. So we expected that we made the circuit fail. But we have checked the stars etc. Does anyone know what the problem might be?

Any inspiration / help is welcome,

thanks,

Justin van til

Try this code.

  #include & lt; SoftwareSerial.h & gt; #include & lt; TinyGPS.h & gt; Tin GPS GPS; Static zero print_long (long value, long invalid, intel lane, int exact); Static zero print_in (unsigned long wal, unsigned long invalid, int lane); Static zero print_date (TNGPS and GPS); Static zero print_st (const four * str, int len); Softwarecierial SS (3,4); Zero setup () {serial.begin (9600); Ss.begin (9600); } Zero loop () {long latitude, lan; Integer alt; Unsigned short sentences = 0, unsuccessful = 0; Gps.get_position (& amp; latitude, and loan); Alt = gps.altitude (); Serial. Print ("Current Latitude and Longueudyu:"); Serial.print (lat); Serial.print (","); Serial.println (longitude); Serial. Print ("Current element:"); Serial.println (optional); Smartdelay (1000); } Fixed zero SmartDelay (unsigned long MS) {unsigned long time start = millise (); Do {while (ss.available ()) gps.encode (ss.read ()); } While (milis () - start  1) serial.print ('*'); Serial. Print (''); } Else {Serial.print (val, prec); Int vi = abs ((int) val); Int flen = prec + (val & lt; 0.0? 2: 1); // And - Flan + = Vi & gt; = 1000? 4: VI & gt; = 100? 3: Vi & gt; = 10? 2: 1; (Int i = flen; i & lt; len; ++ i) serial Print (''); } Smartdale (0); } Fixed Zero print_in (unsigned long wal, unsigned long illegal, Intel lane) {Four SJ [32]; If (val == invalid) strcpy (sz, "*******"); Second Sprintoff (SJ, "% LD", WAL); Sz [len] = 0; For (int i = strlen (sz); i & lt; len; ++ i) sz [i] = ''; If (LAN> 0) sz [len-1] = ''; Serial.print (SZ); Smartdelay (0); } Static zero print_st (const char * str, int len) {int slen = strlen (str); (Int i = 0; i & lt; len; ++ i) serial.print (i  

No comments:

Post a Comment