Request for non-class type...help

I’m getting an error when compiling a code on arduino. I know this is out of context but it says “error: request for member ‘begin’ in ‘2’, which is of non-class type ‘int’”.

I’m new to programming and the resources I am using aren’t helping me.

code.pde:

#define GPS_PIN_1 2 // GPS serial pin 1
#define GPS_PIN_2 3 // GPS serial pin 2
… (missing a bit out here, quite a long start)
void setup() {
Serial.begin(9600);
Serial << F(“Project booting…”) << endl;

// Start the GPS
pinMode(GPS_POWER, OUTPUT);
digitalWrite(GPS_POWER, LOW);
Serial << F("* GPS module switched on!") << endl;
GPS_PIN_1.begin(GPSRATE);
Serial << F("* GPS serial on pins “) << GPS_PIN_1 << F(” and “) << GPS_PIN_2 << F(” started at “) << GPSRATE << F(” baud") << endl;

Error is linked to line " GPS_PIN_1.begin(GPSRATE);"

#define GPS_PIN_1       2   // GPS serial pin 1 
    GPS_PIN_1.begin(GPSRATE);

2.begin(GPSRATE); doesn't make any sense - what are you trying to do with the "begin".

Looks to me like OP wants to define some pins to read a GPS on, using NewSoftSerial. It it the NewSoftSerial instance (not created) that should be used with the begin method, and created using the #define'd pin numbers.

Sorry, I will copy the code out fuller, so that you can see all the libraries I have defined in my setup

// Digital mode pins
#define GPS_PIN_1 2 // GPS serial pin 1
#define GPS_PIN_2 3 // GPS serial pin 2
#define GPS_POWER 4 // Which pin turns the GPS on?
#define RTTY_LED 5
#define GPS_LED 6 // Which LED to light when we have a GPS lock?
#define RTTY_PIN_1 8 // RTTY space pin
#define RTTY_PIN_2 9 // RTTY mark pin
#define LUMIX_PIN 17

// Other stuff
#define RTTY_ASCII 7 // ASCII set for RTTY (7/8bit)
#define GPSRATE 4800 // GPS baud rate
#define BUFFERSIZE 90 // How many bytes of input to buffer from the GPS?

#include <Streaming.h>
#include <NewSoftSerial.h>
#include <Flash.h>
#include <util/crc16.h>

// Initialize flight variables
int numSats = 0;
int fixType = 0;
int time = {0, 0, 0};
double latitude = 0.0;
double longitude = 0.0;
long altitude = 0;
long maxAlt = 0;
int speed = 0;
int txCount = 0;
int bitRate = 50;

//
// Initial setup/bootstrap
//
void setup() {
Serial.begin(9600);
Serial << F(“Project booting…”) << endl;

// Start the GPS, pull low to turn on
pinMode(GPS_POWER, OUTPUT);
digitalWrite(GPS_POWER, LOW);
Serial << F("* GPS module switched on!") << endl;
GPS_PIN_1.begin(GPSRATE);
Serial << F("* GPS serial on pins “) << GPS_PIN_1 << F(” and “) << GPS_PIN_2 << F(” started at “) << GPSRATE << F(” baud") << endl;

As you can see I have called out the “NewSoftSerial” lib

You need something like NewSoftSerial GPSserial (GPS_PIN_1, GPS_PIN_2);

before your "setup", then call the "begin" method on "GPSserial" in setup.

Gonna launch a Lumix, huh?

As you can see I have called out the "NewSoftSerial" lib

But, you haven't created an instance of the class, or told it which pins to use.

NewSoftSerial gps(GPS_PIN_1, GPS_PIN_2); // Might need to be in other order...

Then, it is this instance that you call the begin method for:

gps.begin(GPSRATE);

Thanks alot for the help. It seems that there are quite a few issues with this code, so its going to make more sense to scrap it. Thanks for the assistance though

It seems that there are quite a few issues with this code, so its going to make more sense to scrap it.

Work at it one subsystem at a time, and try to keep things isolated in functions or classes. Don't try and knit all the subsystems together until you are happy they all work well on their own, and then add them one at a time.