Graphing Analogue value with Processing language

Hi

New to Arduino and programming. I am trying to Graph an analogue value from a pot; also tried with a thermistor, using the example program "Graph" in the Arduino library. The problem is with Processing the window pops up but no graph. I can see the analogue value in Arduino changing so I think the hardware is ok.
In the Processing program I put an instruction println after line 38

38 inByte = map(inByte, 0, 1023, 0, height);
39 println(inByte);

In the console I see
COM4
then a list of float values e.g. 117.4231 etc which I can also change!!
I've tried changing colours thinking the line may be hidden, no luck.

I've also written a small bit of code in Processing that increments a gradually increasing line across the window and it works perfectly.
Is this a string to int or float problem? Please help its driving me nuts.

I can see the analogue value in Arduino changing so I think the hardware is ok.

While Processing is running? How?

then a list of float values e.g. 117.4231 etc which I can also change!!

How can you change output values?

Is this a string to int or float problem? Please help its driving me nuts.

People that don't post code, but still want to know what is wrong with it, drive me nuts.

Hi PaulS

I didn't put code into post as it's a click away in the Arduino library. No, not running both at same time. In Arduino monitor shows analogue value changing as I move pot. When in Processing I added the println instruction to see the variable inByte was changing, and it seems to be. So the program seems to be controlling the length of the graphed line with inByte so why is it not showing?

Here's the code:-

/* Graph

A simple example of communication from the Arduino board to the computer:
the value of analog input 0 is sent out the serial port. We call this "serial"
communication because the connection appears to both the Arduino and the
computer as a serial port, even though it may actually use
a USB cable. Bytes are sent one after another (serially) from the Arduino
to the computer.

You can use the Arduino serial monitor to view the sent data, or it can
be read by Processing, PD, Max/MSP, or any other program capable of reading
data from a serial port. The Processing code below graphs the data received
so you can see the value of the analog input changing over time.

The circuit:
Any analog input sensor is attached to analog in pin 0.

created 2006
by David A. Mellis
modified 9 Apr 2012
by Tom Igoe and Scott Fitzgerald

This example code is in the public domain.

*/

void setup() {
// initialize the serial communication:
Serial.begin(9600);
}

void loop() {
// send the value of analog input 0:
Serial.println(analogRead(A0));
// wait a bit for the analog-to-digital converter
// to stabilize after the last reading:
delay(2);
}

/* Processing code for this example

// Graphing sketch

// This program takes ASCII-encoded strings
// from the serial port at 9600 baud and graphs them. It expects values in the
// range 0 to 1023, followed by a newline, or newline and carriage return

// Created 20 Apr 2005
// Updated 18 Jan 2008
// by Tom Igoe
// This example code is in the public domain.

import processing.serial.*;

Serial myPort; // The serial port
int xPos = 1; // horizontal position of the graph

void setup () {
// set the window size:
size(400, 300);

// List all the available serial ports
// if using Processing 2.1 or later, use Serial.printArray()
println(Serial.list());

// I know that the first port in the serial list on my mac
// is always my Arduino, so I open Serial.list()[0].
// Open whatever port is the one you're using.
myPort = new Serial(this, Serial.list()[0], 9600);

// don't generate a serialEvent() unless you get a newline character:
myPort.bufferUntil('\n');

// set inital background:
background(0);
}
void draw () {
// everything happens in the serialEvent()
}

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:
float inByte = float(inString);
inByte = map(inByte, 0, 1023, 0, height);

// draw the line:
stroke(127,34,255);
line(xPos, height, xPos, height - inByte);

// at the edge of the screen, go back to the beginning:
if (xPos >= width) {
xPos = 0;
background(0);
}
else {
// increment the horizontal position:
xPos++;
}
}
}

*/

I didn't put code into post as it's a click away in the Arduino library.

Nonsense. We have no clue what sketch you have loaded, or what changes you made first.

float inByte = float(inString);

That is as stupid a name as has been used in code posted all week. The value is NOT a byte. Get real. Use a name that means something.

We need to see the sending code. The Processing code expects you to be sending an int as a string. Converting that int to a float makes NO sense.

I said I am new to this, also code is not mine I simply copied it from Arduino Files--> examples --> Communications --> Graph and am trying to understand how it works or doesn't seem to work in this case. The sending code in the Arduino is:

void setup() {
// initialize the serial communication:
Serial.begin(9600);
}

void loop() {
// send the value of analog input 0:
Serial.println(analogRead(A0));
// wait a bit for the analog-to-digital converter
// to stabilize after the last reading:
delay(2);
}

String inString = myPort.readStringUntil('\n');

So, what is in inString?

int inDeepShit = int(inString);

So, what is in inDeepShit?

inDeepShit = map(inDeepShit, 0, 1023, 0, height);

So, what is in inDeepShit?

line(xPos, height, xPos, height - inDeepShit);