Processing + Arduino

edited September 2014 in Arduino

I'm trying to work processing + arduino. The idea is to display a video with arduino. I've search about it but I haven't found nothing about, just things about a led. I show the processing code and arduino code. I hope someone could help. Thank you so much.

Processing:

import processing.serial.*; 
import processing.video.*;
Movie myMovie;
int end = 10; // 

String serial; // 

Serial port; // 


void setup() {

  size(200, 200);

  noStroke(); 

rectMode(CORNER);  


port = new Serial(this, Serial.list()[0], 9600); 

port.clear(); 

serial = port.readStringUntil(end); 

serial = null; 

  myMovie = new Movie(this, "sexy.mov");
  myMovie.stop();
}

void draw() {
   image(myMovie, 0, 0);
  background(220); 


  while (port.available() > 0) { 

serial = port.readStringUntil(end); 

if (serial != null) { 

int posY=Integer.parseInt(serial.trim()); 

print("luz: ");

println(posY); 

if(posY==4){

myMovie.play();
}
if(posY==0){

myMovie.stop();

posY=255;
}
background(255); 

image(myMovie, 0, 0);

rect(0,0,300,posY);

fill(0);
}
}

void movieEvent(Movie m) {
  m.read();
}

Arduino code:

int boton = 2;
int boton1 = 3;

// the setup routine runs once when you press reset:

void setup() {

  // initialize serial communication at 9600 bits per second:

  Serial.begin(9600);
  // make the pushbutton's pin an input:

  pinMode(4, INPUT);


}

// the loop routine runs over and over again forever:

void loop() {
  // read the input pin:

  int buttonState = digitalRead(4);

  i
  // print out the state of the button:

  if(buttonState==HIGH){Serial.println("4");

    } 
  //  else if(buttonState==LOW){Serial.println("1");    delay(100);    }



  delay(100);        // delay in between reads for stability
}
Sign In or Register to comment.