Hey Arduinians,
Can you help me? I'm doing something I think is simple, but it doesn't work and I don't understand why. Here's the problem.
I have created the beginnings of a GPS class (to do the obvious) and I want it to instantiate it's own serial connection to the GPS hardware. So the GPS class should instantiate an object of the NewSoftSerial class so it can receive data. Easy. But it fails with the error:
LifeClock99.cpp.o:(.bss.gps+0x0): multiple definition of `gps'
GPS.cpp.o:/GPS.h:17: first defined here
If I instaintate the NewSoftSerial object in the main sketch (commented out below) it compiles just fine. Why is that? Here's all my code.
Main.pde:
#include "GPS.h"
//NewSoftSerial gps(GPS_READ_PIN, GPS_WRITE_PIN);
void setup()
{
Serial.begin(115200);
Serial.println("setup()");
}
void loop()
{
}
GPS.h:
#ifndef GPS_h
#define GPS_h
#include "NewSoftSerial.h"
// Pinouts: http://shieldlist.org/sparkfun/gps
#define GPS_WRITE_PIN 2
#define GPS_READ_PIN 3
#define GPS_BAUD 4800
NewSoftSerial gps(GPS_READ_PIN, GPS_WRITE_PIN);
class GPS
{
public:
private:
};
#endif
GPS.cpp
#include "GPS.h"