# Tracking with a SEN0158

**URL:** <https://discourse.processing.org/t/tracking-with-a-sen0158/6370>\
**Category:** Electronics (Arduino, etc.)\
**Created:** [December 6, 2018, 3:46pm UTC](https://discourse.processing.org/t/tracking-with-a-sen0158/6370 "2018-12-06T15:46:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![POlefef](https://avatars.discourse-cdn.com/v4/letter/p/ecb155/32.png) [@POlefef](https://discourse.processing.org/u/POlefef)\
**Post date:** [December 6, 2018, 3:46pm UTC](https://discourse.processing.org/t/tracking-with-a-sen0158/6370/1 "2018-12-06T15:46:10Z")

</div>

Hello everyone.  
I’m really new at processing and i have to display a graph that gives me the location of infrared sources by using processing and an IR camera (SEN0158)  
I’ve tried multiple times to run the following code which i found on dfrobot but it keeps showing my errors like ArrayIndexOutOfBoundsException: 1 for example.  
Can someone help me to correct this code or tell me what i’m doing wrong?

Thank you a lot for your help.

CODE:

```auto
// Example by Tom Igoe
// Modified for http://www.DFRobot.com by Lumi, Jan. 2014

/*
   This code should show one colored blob for each detected IR source (max four) at the relative position to the camera.
*/

import processing.serial.*;

int lf = 10; // Linefeed in ASCII
String myString = null;
Serial myPort; // The serial port

void setup() {
  // List all the available serial ports
  println(Serial.list());
  // Open the port you are using at the rate you want:
  myPort = new Serial(this, Serial.list()[0], 19200);
  myPort.clear();
  // Throw out the first reading, in case we started reading 
  // in the middle of a string from the sender.
  myString = myPort.readStringUntil(lf);
  myString = null;
  size(800,800);
  //frameRate(30);
}

void draw() {
  background(77);
  //while (myPort.available() > 0) {
    myString = myPort.readStringUntil(lf);
    if (myString != null) {
      int[] output = int (split(myString, ','));

      println(myString); // display the incoming string
         
      int xx = output[0];
      int yy = output[1];
      
      int ww = output[2];
      int zz = output[3];
      
      int xxx = output[4];
      int yyy = output[5];
      
      int www = output[6];
      int zzz = output[7];

      ellipseMode(RADIUS); // Set ellipseMode to RADIUS
      fill(255, 0, 0); // Set fill to white
      ellipse(xx, yy, 20, 20);
      ellipseMode(RADIUS); // Set ellipseMode to RADIUS
      fill(0, 255, 0); // Set fill to white
      ellipse(ww, zz, 20, 20);
      
      ellipseMode(RADIUS); // Set ellipseMode to RADIUS
      fill(0, 0, 255); // Set fill to white
      ellipse(xxx, yyy, 20, 20);
      ellipseMode(RADIUS); // Set ellipseMode to RADIUS
      fill(255); // Set fill to white
      ellipse(www, zzz, 20, 20);

    }
}

```

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [December 8, 2018, 6:41pm UTC](https://discourse.processing.org/t/tracking-with-a-sen0158/6370/2 "2018-12-08T18:41:22Z")

</div>

> [@POlefef](#):
>
> it keeps showing my errors like ArrayIndexOutOfBoundsException: 1

What line number is it showing you that error is occurring on?
