PIR+Arduino+Porcessing = weBcam; wheres my mistake

Hi, i have a problem, cause i tried to open a Processing code (Capture with webcam) when the PIR sensor activates (Controlled by Arduino), but when something moves, the arduino dont call processing so, theres is my question: ¿How could i call processing from arduino when the pir codes calls?

Heres the codes that im using.

#include <Firmata.h>
int sensorPIR = 4;
long tiempoEncendido = 120000; // Tiempo en mili-segundos (30 SEG)
int PIRactivo=0;
long contador = 0;

void setup()

void loop()
if ( PIRactivo==HIGH ) {
} else {

import processing.video.*;

Capture cam;

void setup() {
size(640, 480);

// If no device is specified, will just use the default.
cam = new Capture(this, 320, 240);

// To use another device (i.e. if the default device causes an error),
// list all available capture devices to the console to find your camera.
//String devices = Capture.list();

// Change devices[0] to the proper index for your camera.
//cam = new Capture(this, width, height, devices[0]);

// Opens the settings page for this capture device.

void draw() {
if (cam.available() == true) {
image(cam, 160, 100);
// The following does the same, and is faster when just drawing the image
// without any additional resizing, transformations, or tint.
//set(160, 100, cam);

First, why is this thread a poll? Are you interested in how many people can spot your mistake?

Second, the Arduino sketch includes the Firmata library. Why?

If the Processing application is to be able to pull data from the Arduino, you need to load a specific sketch on the Arduino. That is not the sketch that you have loaded.

In the Arduino sketch, you set PIRactivo to 0 (LOW). Then, in each pass through loop, you check to see if the value has magically changed to HIGH. Since there is no code running on the Arduino to change the value, it will never become HIGH.

Every half second, the loop function is going to write N to the serial port. Why?

The processing sketch does not read any data from the serial port. I would have expected you to read something from the serial port, and do something different based on the value read.