ctasik
YaBB Newbies
Offline
Posts: 2
processing movie
May 2nd , 2008, 1:21am
Hello, I am very new to processing and I need some help. I am trying to send information from Arduino that writes it to serial when a button pushed.Processing is reading information from serial and playing one of the movies. Before I push any buttons it plays sound of all the movies I have. Could you tell me what is wrong with my code or if there is another way to do it. Thank you. // importing the processing serial class import processing.serial.*; import processing.video.*; Movie myMovieT, myMovieA; // definition of window size and framerate int xWidth = 768; int yHeight = 512; int fr = 24; int xsp,ysp,xspeed; // variables for serial connection, portname and baudrate have to be set Serial port; String portname = "/dev/tty.usbserial-A9003XAq"; int baudrate = 9600; int value = 0; String buf=""; void setup(){ // set size and framerate port = new Serial(this, portname, baudrate); size(xWidth, yHeight); frameRate(fr); background(0); myMovieT = new Movie(this, "movie2.mov"); myMovieA = new Movie(this, "movie3.mov"); myMovieT.stop(); myMovieA.stop(); } void serialEvent(int serial){ if(serial == 'G') { myMovieA.stop(); myMovieT.play(); image(myMovieT, 0, 0); println("Ted"); } else if(serial == 'I') { myMovieT.stop(); myMovieA.play(); image(myMovieA, 0, 0); println("Susan"); } } // draw listens to serial port, draw void draw(){ // listen to serial port and trigger serial event while(port.available() > 0){ value = port.read(); serialEvent(value); } myMovieA.read(); myMovieT.read(); }