We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hey yall - firstly thanks for any help.
I am trying to run the very basic "graph" tutorial off of an arduino. (https://www.arduino.cc/en/Tutorial/Graph). I have a simple circuit with a potentiometer.
When I run this processing code, I get the following error:
map(NaN, 0, 1023, 0, 300) called, which returns NaN (not a number)
Weird. But if I type "println(inByte)" after my map line, the console shows me changing potentiometer values just fine. No error. Also, I should say the pop-out window which is supposed to graph my moving values is black, and never shows any sort of graph. Thanks again for all your help -
Answers
i assume that inByte comes as String
so use trim on it
so convert it by
map(float(inByte), 0 .......
and show your code
Thank you for the reply! This is my code:
Again, if I write in a println(inByte); after the last line, the console does display mapped values. However no graph appears. But when I don't print the line, I get this error in the console (and still no graph):
map(NaN, 0, 1023, 0, 300) called, which returns NaN (not a number)
Meaning "inByte" -as its called in the map function - isn't working somehow.
When I tried what I interpreted as your suggestion - tossing "float(inByte)" into my map function - i got the error message: "the function parseFloat(int) expects parameters like: "parseFloat(int)" ". ... Dang!
What type is inString at the start?
Hm, actually not sure. I think it's just listening to whatever is coming out of the serial port?
I dont know... debug it...
I had the same problem and find a solution here: [https://forum.arduino.cc/index.php?topic=351828.0]
This code work for me:
I know this is a year old, but still. You will get the map(NaN) error if your baud rate is set incorrectly in processing.
As in, your Arduino is running at 9600 Baud, and your processing code has: myPort = new Serial(this, Serial.list()[0], 115200);