Hey, I´m kind'a new with this two so I have this code, from upon 5 sources and examples.
The thing is that when I activate the ports of the arduino the image freezes and so the arduino, so i have to kill the java directly from de task manager.
import processing.serial.*;
import SimpleOpenNI.*;
import cc.arduino.*;
Arduino arduino;
SimpleOpenNI kinect;
PImage depthImage;
float closestValue = 800; //Medida Real 804,27cm
float farthestValue = 1000; //Medida Real 994,69cm
void setup() {
size(640, 480);
kinect = new SimpleOpenNI(this);
kinect.enableDepth();
println(Arduino.list());
arduino = new Arduino(this, Arduino.list()[1], 115200);
for (int j = 0; j <= 13; j++)
{
arduino.pinMode(j, Arduino.OUTPUT);
}
}
void draw()
{
kinect.update();
int[] depthValues = kinect.depthMap();
depthImage = kinect.depthImage();
smooth();
arduino.digitalWrite(2, Arduino.HIGH); // Avance
arduino.digitalWrite(3, Arduino.LOW); //Girar a la Derecha (LED Verde)
arduino.digitalWrite(4, Arduino.LOW); //Girar a la Izquierda (LED Amarillo)
arduino.digitalWrite(5, Arduino.LOW); //Freno
for (int x = 0; x < 640; x++)
{
for (int y = 0; y < 480; y++)
{
int i = x + y * 640; //POsicionador de pixeles
int currentDepthValue = depthValues[i]; //Valores actuales de profundidad
//Declaracion para todos los valores diferentes de 80cm y 1m colocar los pixeles a 0
if (currentDepthValue < closestValue || currentDepthValue > farthestValue)