How to store a series of inputs as an array and use it in Processing

HI guys,
i m new to the field of electronics and programming,i have this problem where i hv to store the analoginput as an array to use it in processing..the thing is i dunno how to store the constantly changing data from the sensor as an array and how to use the array in processing.plz help.

Moderator edit: Thread title made not all caps. (Nick Gammon)

Have you worked through any of the examples in either the Arduino or Processing IDEs?

When is your assignment due?

Its not an assignment i m building a radar and i need the array to display the distance..

OK, but which of the examples have you worked through, and what does your code look like?

(PS, please don't shout)

#include  
 int i[18]
int pingPin = 13;
int inPin = 12;
 
void setup() {

}
 
void loop()
{
  // establish variables for duration of the ping,
  // and the distance result in inches and centimeters:
  long duration, inches, cm;
 
  // The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
  // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
  pinMode(pingPin, OUTPUT);
  digitalWrite(pingPin, LOW);
  delayMicroseconds(2);
  digitalWrite(pingPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(pingPin, LOW);
 
  // The same pin is used to read the signal from the PING))): a HIGH
  // pulse whose duration is the time (in microseconds) from the sending
  // of the ping to the reception of its echo off of an object.
  pinMode(inPin, INPUT);
  duration = pulseIn(inPin, HIGH);
 
  // convert the time into a distance
  inches = microsecondsToInches(duration);
  cm = microsecondsToCentimeters(duration);
  lcd.print(cm);
  lcd.print("cm");
 
  delay(100);
}
 
long microsecondsToCentimeters(long microseconds)
{
  // The speed of sound is 340 m/s or 29 microseconds per centimeter.
  // The ping travels out and back, so to find the distance of the
  // object we take half of the distance travelled.
  return microseconds / 29 / 2;
}

well this is the code i found i wanna know if i can use the following to get an array

for(int x=0;x<18;x++)
{
cm=i[x]
}

will this give me an array of data?

#include  
 int i[18]

"include" what, exactly?
"i" isn't the best name for an array of soundings, and the declaration needs a semicolon to terminate the line.

for(int x=0;x<18;x++)
{
cm=i[x]
}

Again, needs more semicolon, and this will simply write the same value into all 18 elements of your array.

Have you worked through any examples?

Thnx... Apart from the semicolons can you gv me solution to the problem..u hv a valid point that all my arrays will hv the same data what should i do to get the varying data and store em in the different arrays...i hv tried tutorials but doesnt seem to work so plz help.....

Must be a slow morning - I didn't notice your assignment was the wrong way round!

for (int i = 0; i < N_READINGS; ++i) {
  sounding [i] = pingRange ();
}

Thnx for the reply i ll try the snippet

You'll probably want this:

unsigned long pinRange (byte pingPin)
{ 
  pinMode(pingPin, OUTPUT);
  digitalWrite(pingPin, LOW);
  delayMicroseconds(2);
  digitalWrite(pingPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(pingPin, LOW);
 
  pinMode(inPin, INPUT);
  return pulseIn(inPin, HIGH);
}