graphing serial port inputs using processing code

I am trying to use the inputs of a potentiometer to graph them using processing code and i am using the sample code generated by Arduino website for beginners:http://arduino.cc/en/Tutorial/Graph but unfortunately i can compile the arduino code but not the processing code. Am i suppposed to have both of codes under the same file or 2 seperate files or their might be even sth trivial since i’m new to Arduino. this is the error i get:
error: ‘import’ does not name a type In function ‘void setup()’:
In function ‘void draw()’:
At global scope:
Any suggestions would be appreciated

You need to have the Processing stuff in one sketch, and the Arduino stuff in another sketch. Then, you use the Arduino IDE to compile the Arduino stuff, and upload it to the Arduino.

Then, you use the Processing IDE to compile the Processing stuff, and run it on the PC.

Thank you very much..I did exactly what you said and it seems to be working except i get an error with this code: PImage myImage; myImage = loadImage("Lcd.jpg"); image (myImage, 0, 0,width,height); it says there is a null pointer..Anybody knows why? maybe the picture has to be under the same directory of the file? maybe i missed to declare or download some library.I know i downloaded 2 zip files..one for Arduino and one for processing and I'm assuming they include everything Thank you for your support again

The loadImage command returns a pointer to the image it loaded. If it can't find the image, it returns a NULL pointer.

maybe the picture has to be under the same directory of the file?

I think there should be a data directory in the Processing sketch directory, in which the picture goes. The instructions where you got the sketch from should have told you where the picture goes.

If this is something you are writing yourself, you can (I'm almost positive) explicitly define where the image is (using something like "C:\Over\There\ImageName.ext"), instead of the "relative to who knows" where method that you are using.

woked great...thank you so much for your support..you guys are awesome...they need people like you to run our country..i'm sure you could've made the world a better place :)

it seems to me the Arduino code does what it does to get the arduino board going which i don't understand how the processing is controlling the Arduino if we can't write the commands in processing IDE to do the work..?? I'm trying to set up an analog pin to read a signal and use the values read to control an LED but i want the processing to control the work not the Arduino code..

The Processing application runs on the PC. The Arduino code runs on the Arduino. The usual way to get Processing to talk to the Arduino is through the serial port. You can send anything to the serial port from Processing, and then write code on the Arduino to read, interpret, and implement it.

You could send “Hey, Arduino buddy, turn on the LED attached to pin 6”, and write code to parse that string to determine what to do. Or, you could send <6,1> which means the same thing, and is a lot easier to parse. (<6,0> would turn it off).

I’m trying to set up an analog pin to read a signal and use the values read to control an LED but i want the processing to control the work not the Arduino code.

If the Arduino is reading sensor data, and deciding whether to turn an LED on, what is there for the Processing application to do?

You could send the analog data from the Arduino to the Processing application, using the serial port, and have the Processing application make decisions. But, why, when the Arduino can do it?