project due tomorrow!!online waiting for help!!

Hey guys~~i have some problems on my program. I was trying to get the readings from the arduino and then using that number as a index to load image from my computer. but i keep getting the "ArrayIndexOutOfBoundsException: 111" report.....
my project is due tomorrow...really appreciate if you could help!!!
code:

```
import processing.serial.*;

Serial myPort;  
int val;  
int i;
PImage[] images = new PImage[i];

void setup()
{
size(400, 400);
String portName = Serial.list()[0];
myPort = new Serial(this, portName, 9600);

images[111] = loadImage("111.jpg");
. // i just omit the other 68 commands between these two
.
.//
images[444] = loadImage("444.jpg");
}

void draw()
{
if ( myPort.available() > 0) {  
  val = myPort.read();      
}
i = val;
image(images[i], 0, 0);
}
```

part of my arduino code:

```
void loop() {
pulseCount = 0;    
while(digitalRead(pulse_in) == 0) {}
while(digitalRead(pulse_in) == 1) {

pulseCount++; }
val1 = (pulseCount * .0000053) * 2;
val1 = 1/val1;
rval1 = val1;
if (rval1 <= 300)
{
  inde1 = 1;
}
else if (rval1 > 300 && rval1 <= 1200)
{
  inde1 = 2;
}
else if (rval1 > 1200 && rval1 <= 3000)
{
  inde1 = 3;
}
else
{
  inde1 = 4;
}
delay(8000);

pulseCount = 0;
while(digitalRead(pulse_in) == 0) {}
while(digitalRead(pulse_in) == 1) {
pulseCount++; } // loop while Hi
val2 = (pulseCount * .0000053) * 2;
val2 = 1/val2; // calculate frequency
rval2 = val2;
if (rval2 <= 300)
{
  inde2 = 1;
}
else if (rval2 > 300 && rval2 <= 1200)
{
  inde2 = 2;
}
else if (rval2 > 1200 && rval2 <= 3000)
{
  inde2 = 3;
}
else
{
  inde2 = 4;
}
delay(8000);

pulseCount = 0;
while(digitalRead(pulse_in) == 0) {}
while(digitalRead(pulse_in) == 1) {
pulseCount++; } // loop while Hi
val3 = (pulseCount * .0000053) * 2;
val3 = 1/val3;
rval3 = val3;
if (rval3 <= 300)
{
  inde3 = 1;
}
else if (rval3 > 300 && rval3 <= 1200)
{
  inde3 = 2;
}
else if (rval3 > 1200 && rval3 <= 3000)
{
  inde3 = 3;
}
else
{
  inde3 = 4;
}
delay(8000);

inde8 = (inde1 * 100) + (inde2 * 10) + inde3;

Serial.print(inde8, DEC);
delay(8000);

}
```

int i;
PImage[] images = new PImage[i];

If this were C, "i" would be zero.
[edit]You may get bonus marks if your code is nicely presented. You'll certainly get credit around here for going back to your posts, clicking on "modify", highlighting the code in the editor and clicking on the "Code" (#) button on the toolbar.[/edit]

thank you for the reply! i just changed the 'i' to 'c ', but it still keep telling me:
images[111] = loadImage("111.jpg");
has problem which is ArrayIndexOutOfBoundsException: 111

And the value of 'c' is...?

The clue is in the "111"

sorry, i am bit slow to get there......
you mean i should give c an initial value?
basically, i get the reading from the ardunio and i simplify the number to 111, 121,.....so i wish i could import these numbers and using them to load the image from the data folder that has the same name--"111.jpg". do you mean i should change the name?

Thanks!

you mean i should give c an initial value?

If you're using it as a dimension of some allocated storage?
Yes, I think you should give it a value.

i give a value to it and change the image[] to image[1], and it works!
thanks!!