Go Down

Topic: LS20031 GPS TinyGPS Issue (Read 1 time) previous topic - next topic

TeamScience

We are working on a project to display ground speed from a LS20031 GPS on a seven segment LED display. We're using TinyGPS and SoftwareSerial. Our code keeps displaying the errors :

Quote
BigLEDwrite:11: error: 'NewSoftSerial' does not name a type
BigLEDwrite.ino: In function 'void setup()':
BigLEDwrite:58: error: 'nss' was not declared in this scope
BigLEDwrite.ino: In function 'void loop()':
BigLEDwrite:92: error: 'nss' was not declared in this scope


What can we do to name NewSoftSerial as a type? And, how can we declare nss?


Here is our code:
We have marked the errors with red.  A lot of the code is for the seven segment LED.

Quote
#include <NewSoftSerial.h>
#include <TinyGPS.h>
TinyGPS gps;

#define PMTK_SET_NMEA_OUTPUT_RMCGGA "$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28\r\n"
#define PMTK_SET_NMEA_UPDATE_1HZ "$PMTK220,200*1F\r\n"
#define PMTK_Q_RELEASE "$PMTK605*31\r\n"

#define RXPIN 3
#define TXPIN 2
NewSoftSerial nss(RXPIN, TXPIN);

//variables
int number[4] = {0,0,0,0};
int del=1;
int velocity=0;

//GPS
//int gps1 = power
//int gps4 = ground
int gps3 = 3;

//segments
int a = 8;
int b = 13;
int c = A0;
int d = A1;
int e = A2;
int f = A3;
int g = A4;
int p = A5;
//digits
int d4 = 9;
int d3 = 10;
int d2 = 11;
int d1 = 12;
//segment and digit arrays
int segment[7]={a,b,c,d,e,f,g};
int digit[4]={d1,d2,d3,d4};
int H=HIGH;
int L=LOW;

int segVal[7]={L,L,L,L,L,L,L};
int ZERO[7]={H,H,H,H,H,H,L};
int ONE[7]={L,H,H,L,L,L,L};
int TWO[7]={H,H,L,H,H,L,H};
int THREE[7]={H,H,H,H,L,L,H};
int FOUR[7]={L,H,H,L,L,H,H};
int FIVE[7]={H,L,H,H,L,H,H};
int SIX[7]={H,L,H,H,H,H,H};
int SEVEN[7]={H,H,H,L,L,L,L};
int EIGHT[7]={H,H,H,H,H,H,H};
int NINE[7]={H,H,H,L,L,H,H};

void setup()
{
  Serial.begin(9600);
  nss.begin(38400);
  while(!nss.available()){}
  nss.print(PMTK_SET_NMEA_OUTPUT_RMCGGA);
  nss.print(PMTK_SET_NMEA_UPDATE_1HZ);
  Serial.print("Test of GPS");
  pinMode(gps3, INPUT);
  pinMode(d1, OUTPUT);
  pinMode(d2, OUTPUT);
  pinMode(d3, OUTPUT);
  pinMode(d4, OUTPUT);
  pinMode(a, OUTPUT);
  pinMode(b, OUTPUT);
  pinMode(c, OUTPUT);
  pinMode(d, OUTPUT);
  pinMode(e, OUTPUT);
  pinMode(f, OUTPUT);
  pinMode(g, OUTPUT);
  pinMode(p, OUTPUT);
  digitalWrite(a, L);
  digitalWrite(b, L);
  digitalWrite(c, L);
  digitalWrite(d, L);
  digitalWrite(e, L);
  digitalWrite(f, L);
  digitalWrite(g, L);
  digitalWrite(p, L);
  digitalWrite(d1,H);
  digitalWrite(d2,H);
  digitalWrite(d3,H);
  digitalWrite(d4,H);
}

void loop()
{
while (nss.available())
  {
    int c = nss.read();
    if(gps.encode(c)){
      int spd=gps.speed();
      Serial.write(spd); // process new gps info here
    }
  }
 
  velocity=134;
  for(int v=3; v>=0; v--){
    number[v]=velocity % 10;
    velocity = velocity / 10;

  }
 
  for(int d=0; d<4; d++){
    switch(d){
    case 0:
      if(number[0]==0){
        digitalWrite(d1,H); digitalWrite(d2,H); digitalWrite(d3,H); digitalWrite(d4,H);
      }
      else {
        digitalWrite(d1,L); digitalWrite(d2,H); digitalWrite(d3,H); digitalWrite(d4,H);
      }
      break;
    case 1:
      if(number[0]==0 && number[1]==0){
        digitalWrite(d1,H); digitalWrite(d2,H); digitalWrite(d3,H); digitalWrite(d4,H);
      }
      else {
        digitalWrite(d1,H); digitalWrite(d2,L); digitalWrite(d3,H); digitalWrite(d4,H);
      }
      break;
    case 2:
      digitalWrite(d1,H); digitalWrite(d2,H); digitalWrite(d3,L); digitalWrite(d4,H);
      break;
    case 3:
      digitalWrite(d1,H); digitalWrite(d2,H); digitalWrite(d3,H); digitalWrite(d4,L);
      break;
    }

    numseg(number[d]);
    for(int i=0;i<7;i++){
      digitalWrite(segment,segVal);
    }
    delay(del);
    for(int i=0; i<7; i++){
      digitalWrite(segment,L);
    }
  }
}


void numseg(int n)
{
  switch(n)
  {
    case 0:
      for(int i=0;i<7;i++){
        segVal=ZERO;
      }
      break;
    case 1:
      for(int i=0;i<7;i++){
        segVal=ONE;
      }
      break;
    case 2:
      for(int i=0;i<7;i++){
        segVal=TWO;
      }
      break;
    case 3:
      for(int i=0;i<7;i++){
        segVal=THREE;
      }
      break;
    case 4:
      for(int i=0;i<7;i++){
        segVal=FOUR;
      }
      break;
    case 5:
      for(int i=0;i<7;i++){
        segVal=FIVE;
      }
      break;
    case 6:
      for(int i=0;i<7;i++){
        segVal=SIX;
      }
      break;
    case 7:
      for(int i=0;i<7;i++){
        segVal=SEVEN;
      }
      break;
    case 8:
      for(int i=0;i<7;i++){
        segVal=EIGHT;
      }
      break;
    case 9:
      for(int i=0;i<7;i++){
        segVal=NINE;
      }
      break;
  }
}




TeamScience

#2
Apr 14, 2013, 06:24 pm Last Edit: Apr 14, 2013, 06:31 pm by TeamScience Reason: 1
Re-post from Other Software Development.  We didn't realize where we were posting (new to this)
We are working on a project to display ground speed from a LS20031 GPS on a seven segment LED display using an Arduino UNO. We're using TinyGPS and SoftwareSerial. Our code keeps displaying the errors :

Code: [Select]
BigLEDwrite:11: error: 'NewSoftSerial' does not name a type
BigLEDwrite.ino: In function 'void setup()':
BigLEDwrite:58: error: 'nss' was not declared in this scope
BigLEDwrite.ino: In function 'void loop()':
BigLEDwrite:92: error: 'nss' was not declared in this scope


What can we do to name NewSoftSerial as a type? And, how can we declare nss?

Here is the datasheet for the LS20031: https://www.sparkfun.com/datasheets/GPS/Modules/LS20030~3_datasheet_v1.2.pdf
Here is our code:
We have marked the errors with red.  A lot of the code is for the seven segment LED.

Code: [Select]
#include <NewSoftSerial.h>
#include <TinyGPS.h>
TinyGPS gps;

#define PMTK_SET_NMEA_OUTPUT_RMCGGA "$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28\r\n"
#define PMTK_SET_NMEA_UPDATE_1HZ "$PMTK220,200*1F\r\n"
#define PMTK_Q_RELEASE "$PMTK605*31\r\n"

#define RXPIN 3
#define TXPIN 2
[color=red]NewSoftSerial nss(RXPIN, TXPIN);
[/color]
//variables
int number[4] = {0,0,0,0};
int del=1;
int velocity=0;

//GPS
//int gps1 = power
//int gps4 = ground
int gps3 = 3;

//segments
int a = 8;
int b = 13;
int c = A0;
int d = A1;
int e = A2;
int f = A3;
int g = A4;
int p = A5;
//digits
int d4 = 9;
int d3 = 10;
int d2 = 11;
int d1 = 12;
//segment and digit arrays
int segment[7]={a,b,c,d,e,f,g};
int digit[4]={d1,d2,d3,d4};
int H=HIGH;
int L=LOW;

int segVal[7]={L,L,L,L,L,L,L};
int ZERO[7]={H,H,H,H,H,H,L};
int ONE[7]={L,H,H,L,L,L,L};
int TWO[7]={H,H,L,H,H,L,H};
int THREE[7]={H,H,H,H,L,L,H};
int FOUR[7]={L,H,H,L,L,H,H};
int FIVE[7]={H,L,H,H,L,H,H};
int SIX[7]={H,L,H,H,H,H,H};
int SEVEN[7]={H,H,H,L,L,L,L};
int EIGHT[7]={H,H,H,H,H,H,H};
int NINE[7]={H,H,H,L,L,H,H};

void setup()
{
 Serial.begin(9600);
[color=red]  nss.begin(38400);[/color]
 while(!nss.available()){}
 nss.print(PMTK_SET_NMEA_OUTPUT_RMCGGA);
 nss.print(PMTK_SET_NMEA_UPDATE_1HZ);
 Serial.print("Test of GPS");
 pinMode(gps3, INPUT);
 pinMode(d1, OUTPUT);
 pinMode(d2, OUTPUT);
 pinMode(d3, OUTPUT);
 pinMode(d4, OUTPUT);
 pinMode(a, OUTPUT);
 pinMode(b, OUTPUT);
 pinMode(c, OUTPUT);
 pinMode(d, OUTPUT);
 pinMode(e, OUTPUT);
 pinMode(f, OUTPUT);
 pinMode(g, OUTPUT);
 pinMode(p, OUTPUT);
 digitalWrite(a, L);
 digitalWrite(b, L);
 digitalWrite(c, L);
 digitalWrite(d, L);
 digitalWrite(e, L);
 digitalWrite(f, L);
 digitalWrite(g, L);
 digitalWrite(p, L);
 digitalWrite(d1,H);
 digitalWrite(d2,H);
 digitalWrite(d3,H);
 digitalWrite(d4,H);
}

void loop()
{
[color=red] while (nss.available())[/color]
 {
   int c = nss.read();
   if(gps.encode(c)){
     int spd=gps.speed();
     Serial.write(spd); // process new gps info here
   }
 }
 
 velocity=134;
 for(int v=3; v>=0; v--){
   number[v]=velocity % 10;
   velocity = velocity / 10;

 }
 
 for(int d=0; d<4; d++){
   switch(d){
   case 0:
     if(number[0]==0){
       digitalWrite(d1,H); digitalWrite(d2,H); digitalWrite(d3,H); digitalWrite(d4,H);
     }
     else {
       digitalWrite(d1,L); digitalWrite(d2,H); digitalWrite(d3,H); digitalWrite(d4,H);
     }
     break;
   case 1:
     if(number[0]==0 && number[1]==0){
       digitalWrite(d1,H); digitalWrite(d2,H); digitalWrite(d3,H); digitalWrite(d4,H);
     }
     else {
       digitalWrite(d1,H); digitalWrite(d2,L); digitalWrite(d3,H); digitalWrite(d4,H);
     }
     break;
   case 2:
     digitalWrite(d1,H); digitalWrite(d2,H); digitalWrite(d3,L); digitalWrite(d4,H);
     break;
   case 3:
     digitalWrite(d1,H); digitalWrite(d2,H); digitalWrite(d3,H); digitalWrite(d4,L);
     break;
   }

   numseg(number[d]);
   for(int i=0;i<7;i++){
     digitalWrite(segment[i],segVal[i]);
   }
   delay(del);
   for(int i=0; i<7; i++){
     digitalWrite(segment[i],L);
   }
 }
}


void numseg(int n)
{
 switch(n)
 {
   case 0:
     for(int i=0;i<7;i++){
       segVal[i]=ZERO[i];
     }
     break;
   case 1:
     for(int i=0;i<7;i++){
       segVal[i]=ONE[i];
     }
     break;
   case 2:
     for(int i=0;i<7;i++){
       segVal[i]=TWO[i];
     }
     break;
   case 3:
     for(int i=0;i<7;i++){
       segVal[i]=THREE[i];
     }
     break;
   case 4:
     for(int i=0;i<7;i++){
       segVal[i]=FOUR[i];
     }
     break;
   case 5:
     for(int i=0;i<7;i++){
       segVal[i]=FIVE[i];
     }
     break;
   case 6:
     for(int i=0;i<7;i++){
       segVal[i]=SIX[i];
     }
     break;
   case 7:
     for(int i=0;i<7;i++){
       segVal[i]=SEVEN[i];
     }
     break;
   case 8:
     for(int i=0;i<7;i++){
       segVal[i]=EIGHT[i];
     }
     break;
   case 9:
     for(int i=0;i<7;i++){
       segVal[i]=NINE[i];
     }
     break;
 }
}


PaulS

NewSoftSerial was replaced by SoftwareSerial starting at 1.0.0.

TeamScience

Thats what we thought too but the code wasn't recognizing SoftwareSerial.h (didn't turn orange).  I just tried NewSoftSerial.h and it worked so we left it as that.  If I use SoftwareSerial.h, there are no errors but it doesn't actually say anything on the serial monitor

ijm51000

Just a thought, should the below line not be of type char?

int c = nss.read();

Nick Gammon

Please do not cross-post. This wastes time and resources as people attempt to answer your question on multiple threads.

This is nothing to do with installing your Arduino.

Threads merged.

How to use this forum

Code tags. Grrr.

- Moderator

Go Up