question regarding parseInt and parseFloat

Dear all,

Using Arduino 1.0, I recently learned about parseInt(), very handy for my prject. I would like to interprete a GPS stream of data.

Serial.print(mySerial.find("$GP")) just works fine, but I have no clue as to how to use parseInt()

Hope someone knows how to explain this to me.

Best regards,
Bert

Serial.print(mySerial.find("$GP")) just works fine, but I have no clue as to how to use parseInt()

That snippet tells us nothing about what the mySerial object is. The entire post tells us nothing about what class has parseInt() or parseFloat() methods that you want to use, so we can't go look at the documentation that you should be looking at.

Sorry for this shortage on information.
Below is the experimental code I use only to find ot how the stuff works.
It is based on the SoftwareSerial example by Tom Igoe
based on examples by David Mellis and Heather Dewey-Hagborg
written: 6 Jan 2007

Both mySerial.find("$GP") and parseInt(list) are explained in the Reference section of Stream, just below the Serial section.
(Stream - Arduino Reference)

*/

// include the SoftwareSerial library so you can use its functions:
#include <SoftwareSerial.h>

#define rxPin 2
#define txPin 3

// set up a new serial port
SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);
byte pinState = 0;

void setup() {
// define pin modes for tx, rx, led pins:
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);

// set the data rate for the SoftwareSerial port
mySerial.begin(4800);
Serial.begin(9600);
}

void loop() {
// listen for new serial coming in:
if(mySerial.available())
{
Serial.print(mySerial.find("$GP")); //this actually finds the characters in the stream.

// Serial.print(mySerial.parseInt(list);
char someChar = mySerial.read();
// print out the character:
Serial.print(someChar);
}

}

It appears that the parseInt() and parseFloat() documentation is wrong. What a surprise. Not.

The functions actually take no arguments. So, you should be able to get an integer or a float value from a stream using:

int anInt = mySerial.parseInt();
float aFloat = mySerial.parseFloat();

Thank you, I couldn't figure out wth the parseFloat argument meant either!
:roll_eyes: