GPS robot

Hi
i have an arduino duemilanove, GPS and a old rc car. My plan is to build a GPS controlled car which mens that the car gets a coordinate and it should go to that defined point.
Now I have a problem. The car is controlled by servos and when the GPS nmea data stream comes to the arduino the servos go in the 180 of 180 position! I have no idea how i can fix this problem!
Please help me ! =D

This is the code:

#include <Servo.h>
#include <nmea.h>
#include <NewSoftSerial.h>

NewSoftSerial nss(2, 3);
NMEA gps(GPRMC);

Servo Lenkservo;

int led = 13;
int val = 10;
double soll_lat = 53.1640;
double soll_lon = 008.65775;
double lat;
double lon;

void setup() {
Serial.begin(9600);
nss.begin(4800);
pinMode(13, OUTPUT);
Lenkservo.attach(6);
}
void loop() {
if (nss.available() > 0 ) {
digitalWrite(led, HIGH);
char c = nss.read();
if (gps.decode(c)) {
lat = gps.gprmc_latitude();
lon = gps.gprmc_longitude();
}
if (lat > 52.00000)
{
Lenkservo.write(100);
}
else
{
Lenkservo.write(20);
}
}
}

Do you have the ground wire of the servo connected to the ground of the Arduino?

johnwasser:
Do you have the ground wire of the servo connected to the ground of the Arduino?

yes =D
i have no idea what the problem could be!

is anybody here who can help me! its for a school project and I search for the problem since two weeks!

The car is controlled by servos and when the GPS nmea data stream comes to the arduino the servos go in the 180 of 180 position!

You aren't commanding the servo to go to that position, so if it is moving on it's own, something else is going on, like the Arduino resetting.

You initiate serial communication, but never print anything to the Serial Monitor. It's time that you did.

I search for the problem since two weeks!

Without making any attempts to output any debug info? Hard to understand.

PaulS:
You aren't commanding the servo to go to that position, so if it is moving on it's own, something else is going on, like the Arduino resetting.

You initiate serial communication, but never print anything to the Serial Monitor. It's time that you did.

I did serial communication an there is a data stream like there is no servo attached. The Arduino does not reset.
I command the servo to go to position 100 if lat is over 52.00000 and if it is under 52.00000 it have to go to 20.

Neumi

I did serial communication an there is a data stream like there is no servo attached.

What does "like there is no servo attached"? Do you get serial data appearing in the serial monitor when the servo is attached?

What are you printing to the serial monitor?

When does the servo move incorrectly? If you comment out the calls that you make to move the servo, does the servo still move when it should not?

PaulS:
What does "like there is no servo attached"? Do you get serial data appearing in the serial monitor when the servo is attached?
What are you printing to the serial monitor?
When does the servo move incorrectly? If you comment out the calls that you make to move the servo, does the servo still move when it should not?

The serial monitor prints the latitude and longitude. When the servo is attached the serial monitor prints the same as there is no servo attached.

When the new data stream comes from the GPS the servo goes to 0. and if the stream is ready the servo goes to its defined position.
sorry for my bad english!

Neumi

When the new data stream comes from the GPS the servo goes to 0.

You haven't commanded the servo to do this, have you?

How are you powering the servo? Not from the Arduino, I hope.

PaulS:
You haven't commanded the servo to do this, have you?

How are you powering the servo? Not from the Arduino, I hope.

No i have not command the servo to do that! :slight_smile:

I power the servo from the ESC from the RC car ... the arduino is powered of the ESC too.

I power the servo from the ESC from the RC car

Ummm. The ESC is not a source of power. Batteries are.

A schematic of all the pieces involved would be useful.

I found the problem ...
The NewSoftSerial library was the problem... now I take the normal Serial function ... but now i canĀ“t print something to the Serial Monitor.
Thanks for the help! :slight_smile: