Processing and PIR motion sensor

Processing sketch working great, which i can play video from hdd and I am trying to trigger video or Processing sketch from with PIR motion sensor. I also tested motion sensor with Arduino led pins, it’s flashing when PIR sensor detect motion.

How can I connect this two sketch each other and i can play any video file with PIR motion sensor in Processing.

Thank you!

int ledPin = 13;                // choose the pin for the LED
int inputPin = 3;               // choose the input pin (for PIR sensor)
int pirState = LOW;             // we start, assuming no motion detected
int val = 0;                    // variable for reading the pin status
void setup() {
  pinMode(ledPin, OUTPUT);      // declare LED as output
  pinMode(inputPin, INPUT);     // declare sensor as input
void loop() {
  val = digitalRead(inputPin);  // read input value
  if (val == HIGH) {            // check if the input is HIGH
    digitalWrite(ledPin, HIGH);  // turn LED ON
    if (pirState == LOW) {
      // we have just turned on
      Serial.println("Motion detected!");
      // We only want to print on the output change, not state
      pirState = HIGH;
  } else {
    digitalWrite(ledPin, LOW); // turn LED OFF
    if (pirState == HIGH) {
      // we have just turned of
      Serial.println("Motion ended!");
      // We only want to print on the output change, not state
      pirState = LOW;


import processing.serial.Serial;
static final int PORT_INDEX = 0, BAUDS = 9600;
String myString;
Movie video;
void setup() {
  video = new Movie(this,"render.mp4");
  final String[] ports = Serial.list();
  new Serial(this, ports[PORT_INDEX], BAUDS).bufferUntil(ENTER);
void draw() {
void serialEvent(final Serial s) {
  myString = s.readString().trim();
  redraw = true;
  if (myString.equals("Motion detected!")) {
void movieEvent(Movie video) {;