Array Index out of bounds exception error.

edited February 2016 in Arduino

Basically what im trying to do is to communicate an arduino with processing to graph the temperature.

Im sending this from arduino via serial :

Serial.print(superior); Serial.print(","); Serial.print(inferior); Serial.print(","); Serial.println(valor_sensor_enviar);

delay(2000);

pantallazo1

so I basically need to store "superior" and "inferior" and represent the third variable data which is continuosly changing between 50 and 0.

So I tried this :

import processing.serial.*;

Serial port;

int i,k; int temp; String buffer; int[] valor_anterior=new int[150]; int[] valor_auxiliar=new int[150]; int[] datos=new int[10]; int[] pdatos=new int[10]; int x=65; int nX=400,nY=400; int j; int valor_supeior; int valor_inferior; int saltodelinea=10;

void setup()
{

port = new Serial(this, Serial.list()[1], 9600); background(255);

size(700 ,400); }

void draw() { if(port.available()>=1){

            buffer = port.readStringUntil(saltodelinea);
            port.clear();
            if (buffer != null) {
            buffer = trim(buffer);
            datos = int(split(buffer, ',')); 
            }}}

It works for a short period of time and then crashes giving me the error in the title of this post. Ive been investigating about the error and it seems to be a problem of space in the array I declared. Actually im "SUPOSED" so save 3 INTs in a vector which has space for 10 of them, so why does it crash? Can anyone help me out?

Answers

Sign In or Register to comment.