user14041: I am using pressure sensor with Arduino Uno within Processing.
Given these variables:
Serial myPort;              //the serial port
float sensorValue = 0;      //the value form the sensor

Arduino is printing float numbers on Processing console, according to the snippet below.
(...)

void serialEvent (Serial myPort){
//get the ASCII string
String inString = myPort.readStringUntil('\n');

if (inString != null){
//trim off any whitespace:
inString = trim(inString);
//convert to an int and map to the screen height
sensorValue = float(inString);
println(sensorValue);
sensorValue = map(sensorValue, 0, 1023, 0, height);
//println(sensorValue);

However, I am getting a NaN exception: 
sensorValue = map(NaN, 0, 1023, 0, height);
how is this possible? printing numbers that aren't numbers?

user4143: //convert to an int and map to the screen height
sensorValue = float(inString);
You can't convert a String to a Float just like that by casting.  You have to interpret the characters within the String.  Oh, and a float isn't an integer.
All you're doing there is trying to cast the address of the String object to a float, which it really doesn't like, hence you get NaN.
Try:
int sensorValue;
sensorValue = inString.toInt();


14041: <p>I am using pressure sensor with Arduino Uno within Processing.
Given these variables:</p>

<pre><code>Serial myPort;              //the serial port
float sensorValue = 0;      //the value form the sensor
</code></pre>

<p>Arduino is printing float numbers on Processing console, according to the snippet below.</p>

<pre><code>(...)

void serialEvent (Serial myPort){
//get the ASCII string
String inString = myPort.readStringUntil('\n');

if (inString != null){
//trim off any whitespace:
inString = trim(inString);
//convert to an int and map to the screen height
sensorValue = float(inString);
println(sensorValue);
sensorValue = map(sensorValue, 0, 1023, 0, height);
//println(sensorValue);
</code></pre>

<p>However, I am getting a <code>NaN</code> exception: </p>

<p><code>sensorValue = map(NaN, 0, 1023, 0, height);</code></p>

<p>how is this possible? printing numbers that aren't numbers?</p>
 4143: <p>//convert to an int and map to the screen height
sensorValue = float(inString);</p>

<p>You can't convert a String to a Float just like that by casting.  You have to interpret the characters within the String.  Oh, and a float isn't an integer.</p>

<p>All you're doing there is trying to cast the address of the String object to a float, which it really doesn't like, hence you get NaN.</p>

<p>Try:</p>

<pre><code>int sensorValue;
sensorValue = inString.toInt();
</code></pre>
