Go Down

Topic: GPS (Read 529 times) previous topic - next topic


I have a parallax GPS that works with my Arduino (non mega). The way I always used it was by using the RX pin (0) and sending the information to a software serial to a LCD screen. That has always worked but now I am trying to send the information through the USB serial port of my computer. I tried both hooking up the GPS to the RX pin and using the GPS through software serial, once I open the Serial monitor the GPS stops sending information

On my Arduino it says Luigino 328, I know when I ordered this it has an extra feature that closes the serial port when uploading (so you can leave devices plugged into the serial port.) I don't know if this will affect it or not.

code below
Code: [Select]
#include <string.h>
#include <ctype.h>

#define bit9600Delay 84 
#define halfBit9600Delay 42
#define bit4800Delay 188
#define halfBit4800Delay 94

#include <SoftwareSerial.h>

SoftwareSerial gps(2, 3);

int ledPin = 13;                  // LED test pin
int rxPin = 2;                    // RX PIN
int txPin = 3;                    // TX TX
int byteSerial=-1;
char linea[300] = "";
char comandoGPR[7] = "$GPRMC";
int cont=0;
int bien=0;
int conta=0;
int indices[13];

void setup() {

   pinMode(ledPin, OUTPUT);       // Initialize LED pin
   pinMode(rxPin, INPUT);
   pinMode(txPin, OUTPUT);
   for (int i=0;i<300;i++){       // Initialize a buffer for received data
     linea[i]=' ';

void loop() {
   digitalWrite(ledPin, HIGH);
   byteSerial=gps.read();         // Read a byte of the gps port
    Serial.println(byteSerial, BYTE);     
   if (byteSerial == -1)
   {           // See if the port is empty yet
   } else {
     linea[conta]=byteSerial;        // If there is gps port data, it is put in the buffer
     gps.print(byteSerial, BYTE);
     if (byteSerial==13)   // If the received byte is = to 13, end of transmission
       digitalWrite(ledPin, LOW);
       for (int i=1;i<7;i++){     // Verifies if the received command starts with $GPR
         if (linea[i]==comandoGPR[i-1]){
       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
           if (linea[i]=='*'){    // ... and the "*"
             int i = map(analogRead(A0),0,1023,0,9);
             case 0 :Serial.print("Time ")   ;break;
             case 1 :Serial.print("Status ");break;
             case 2 :Serial.print("Lat ");break;
             case 3 :Serial.print("Dir ");break;
             case 4 :Serial.print("Long ");break;
             case 5 :Serial.print("Dir ");break;
             case 6 :Serial.print("Velo ");break;
             case 7 :Serial.print("Head ");break;
             case 8 :Serial.print("Date ");break;
             case 9 :Serial.print("Magn ");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.println("---------------");
       conta=0;         // Reset the buffer
       for (int i=0;i<300;i++){    // 
         linea[i]=' ';             

Thank you for your help
All of my projects --> http://www.frankmagazu.com/


Jul 03, 2012, 11:40 pm Last Edit: Jul 03, 2012, 11:52 pm by arduinopi Reason: 1
Okay, I think it is because of the software serial. The GPS does not seem to work with software serial. Any ideas?

I connected the GPS to RX (0) and the LCD to TX (1) it functions normally (except for different baud rate of GPS and LCD) but once I open the Serial Window It stops pin 13 does not go LOW
All of my projects --> http://www.frankmagazu.com/

Go Up