project due tomorrow!!online waiting for help!!


hey guys~~i have problems on program. trying readings arduino , using number index load image computer. keep getting "arrayindexoutofboundsexception: 111" report.....
my project due tomorrow...really appreciate if help!!!
code:

[glow]
code: [select]
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");
. // omit other 68 commands between these 2
.
.//
images[444] = loadimage("444.jpg");
}

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

part of arduino code:
[glow]
code: [select]
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);

}
[/glow]


Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > project due tomorrow!!online waiting for help!!


arduino

Comments