Howdy, Stranger!

We are about to switch to a new forum software. Until then we have removed the registration on this forum.

  • Processing (image display) via Arduino ultrasonic sensor

    Hi, I am just starting to explore posibilities to make something work in processing via arduino (sensors). On school exhibition I want to make a picture display that shows one image at the time on the wall (with a projector), depending how close or far person is located from distance sensor. This is a sketch of what I am thinking about:example To see if it really works, I explored some tutorials that explains how to connect Arduino input with Processing. Currently, I have these codes in both programs: for Arduino:

    const int anPin1 = 0;
    long distance1;
    
    void setup() {
      Serial.begin(9600);  // sets the serial port to 9600
    }
    
    void read_sensors(){
      /*
      Scale factor is (Vcc/512) per inch. A 5V supply yields ~9.8mV/in
      Arduino analog pin goes from 0 to 1024, so the value has to be divided by 2 to get the actual inches
      */
      distance1 = analogRead(anPin1)/2;
    }
    
    void print_all(){
      /*
      Serial.print("S1");
      Serial.print("inches");
      */
      Serial.print(" ");
      Serial.print(distance1);
      Serial.println();
    }
    
    void loop() {
      read_sensors();
      print_all();
      delay(50); 
    }
    

    And for Processing:

    import processing.serial.*;  
    Serial myPort;  
    String data="" ;
    PFont  myFont;  
    int distance;
    
    void setup(){
      size(1366,900); // size of processing window
      //background(0);// setting background color to black
    
      myPort = new Serial(this, "/dev/cu.usbmodemfd111", 9600);
      myPort.bufferUntil('\n');
    }
    
    void draw(){
    
      background(0);
      textAlign(CENTER);
      fill(255);
      text(data,820,400);
      textSize(100);
      fill(#4B5DCE);
      text("              Distance :        cm",450,400);
      noFill();
      stroke(#4B5DCE);
    
    }
    
    void serialEvent(Serial myPort){
    
      data=myPort.readStringUntil('\n');
    
    }
    

    And this distance reading works perfect!

    Unfortunately didn’t found any specific example for what i am looking for. So the question is, how can I get, for example, 3 pictures working this way:

    if(distance>60){
    image(photo1, 0, 0); //display first photograpgy
    }
    else if (40<distance<60) {
    image(photo2, 0, 0);
    }
    else if (distance<40) {
    image(photo3, 0, 0);
    }
    

    Do I have to write something like that in draw ()? And how can I get income distance value as number from which depends displayed image? And should I upload any specific library for this? Do i have to write something also again in Arduino code?

    Would be great if someone could suggest any examples or codes for this.

    Hoping for advise, komats!!

  • How can I get sound to fade in and out depending on your location?

    In Processing, press Ctrl+t to format your code in the PDE. Then copy and paste the code and format it in the forum (exactly as you have done above).

    This could be relevant: https://forum.processing.org/two/discussion/25094/set-distance-value-with-ultrasonic-sensor#latest

    Right now, what does your code do? Can you get any fading at all? Please notice we don't have the videos nor your setup (not kinect here). Can you comment on what type of kinect unit are you using?

    For volume, check these:

    https://forum.processing.org/two/discussion/13521/minim-help-with-volume-control
    https://forum.processing.org/two/discussion/7237/how-to-set-volume-in-minim

    Kf

  • Collision detection between 2 objects with an ultrasonic sensor (Arduino)

    I do know the basics yes, I've made my own processing game for an assignment in the past which included multiple object collisions, however the main object was controlled by mouseX and mouseY instead of an ultrasonic sensor.

    Sorry I don't understand what you mean by 'what type is the plane/cloud collision?'

  • Collision detection between 2 objects with an ultrasonic sensor (Arduino)

    So I'm working from the code in Step 6 (I will attach below) of this tutorial: http://www.instructables.com/id/How-to-control-a-simple-Processing-game-with-Ardui/

    I am using an HR-SR04 ultrasonic sensor to control the plane, moving it up and down via hand movements.

    What I am trying to do is implement an obstacle feature to the game, by having the score decrease by 1 when the plane hits a cloud. However I can't get the collision detection working for when the plane hits a cloud. The original author has managed to get this working perfectly for when the plane hits the bird but I'm not sure how to get it working between the plane and clouds, I've tried everything I can think of but I'm stuck.

    Any help would be appreciated.

    Below is the code that I'm working from:

    `//Ultrasound plane, a game with a plane and an ultrsound sensor (but
    
    //by Yoruk for Instructables
    
    //send commments or questions to Yoruk16_72 AT yahoo DOT fr
    
    
    //19 07 14 : initial code
    //20 07 14 : it works with arduino !!
    //07 07 15 : picture for the plane and for the grass
    //06 12 15 : score system with the bird
    
    
    int i, j; 
    
    int Score ;
    float DistancePlaneBird;
    
    
    float Hauteur; //en Y
    float Angle;
    int DistanceUltra;
    int IncomingDistance;
    //float Pas; //pour deplacements X
    
    float BirdX;
    float BirdY;
    
    float GrassX ;  //for X position
    
    
    
    
    String DataIn; //incoming data on the serial port
    
    //5 a 32 cm
    
    
    float [] CloudX = new float[6];
    float [] CloudY = new float[6];
    
    //vitesse constante hein
    
    
    PImage Cloud;
    PImage Bird;
    PImage Plane;
    PImage Grass;
    
    
    
    // serial port config
    import processing.serial.*; 
    Serial myPort;    
    
    
    
    //preparation
    void setup() 
    {
    
        myPort = new Serial(this, "/dev/cu.usbmodem1411", 9600); 
    
        myPort.bufferUntil(10);   //end the reception as it detects a carriage return
    
        frameRate(30); 
    
        size(800, 600);
        rectMode(CORNERS) ; //we give the corners coordinates 
        noCursor(); //why not ?
        textSize(16);
    
        Hauteur = 300; //initial plane value
    
    
        Cloud = loadImage("cloud.png");  //load a picture
        Bird = loadImage("bird.png");  
        Plane = loadImage("plane.png");  //the new plane picture
    
            Grass = loadImage("grass.png");  //some grass
    
    
        //int clouds position
        for  (int i = 1; i <= 5; i = i+1) {
            CloudX[i]=random(1000);
            CloudY[i]=random(400);
        }
    
    
        Score = 0;
    }
    
    
    //incoming data event on the serial port
    
    
    void serialEvent(Serial p) { 
        DataIn = p.readString(); 
        // println(DataIn);
    
        IncomingDistance = int(trim(DataIn)); //conversion from string to integer
    
        println(IncomingDistance); //checks....
    
        if (IncomingDistance>1  && IncomingDistance<100 ) {
            DistanceUltra = IncomingDistance; //save the value only if its in the range 1 to 100     }
        }
    }
    
    
    //main drawing loop
    void draw() 
    {
        background(0, 0, 0);
        Ciel(); //draw the sky
        fill(5, 72, 0);
    
    
    
        //rect(0, 580, 800, 600); //some grass
    
        //new grass : 
    
        for  (int i = -2; i <= 4; i = i+1) {  //a loop to display the grass picture 6 times
    
            image(Grass, 224*i  + GrassX, 550, 224, 58);  // 224 58 : picture size
        }
    
        //calculates the X grass translation. Same formulae than the bird
        GrassX = GrassX  -  cos(radians(Angle))*10;
    
        if (GrassX < -224) {  //why 224 ? to have a perfect loop
            GrassX=224;
        }
    
    
        text(Angle, 10, 30); //debug things...
        text(Hauteur, 10, 60); 
    
    
        //new part : check the distance between the plane and bird and increase the score
        DistancePlaneBird = sqrt(pow((400-BirdX), 2) + pow((Hauteur-BirdY), 2)) ;
    
        if (DistancePlaneBird < 40) {
            //we hit the bird   
            Score = Score+ 1;
    
            //reset the bird position
            BirdX = 900;
            BirdY = random(600);
        }
    
        //here we draw the score
        text("Score :", 200, 30); 
        text( Score, 260, 30); 
    
    
    
        //Angle = mouseY-300; //uncomment this line and comment the next one if you want to play with the mouse
        Angle = (18- DistanceUltra)*4;  // you can increase the 4 value...
    
    
    
        Hauteur = Hauteur + sin(radians(Angle))*10; //calculates the vertical position of the plane
    
        //check the height range to keep the plane on the screen 
        if (Hauteur < 0) {
            Hauteur=0;
        }
    
        if (Hauteur > 600) {
            Hauteur=600;
        }
    
        TraceAvion(Hauteur, Angle);
    
        BirdX = BirdX - cos(radians(Angle))*10;
    
        if (BirdX < -30) {
            BirdX=900;
            BirdY = random(600);
        }
    
        //draw and move the clouds
        for  (int i = 1; i <= 5; i = i+1) {
            CloudX[i] = CloudX[i] - cos(radians(Angle))*(10+2*i);
    
            image(Cloud, CloudX[i], CloudY[i], 300, 200);
    
            if (CloudX[i] < -300) {
                CloudX[i]=1000;
                CloudY[i] = random(400);
            }
        }
    
        image(Bird, BirdX, BirdY, 59, 38); //displays the useless bird. 59 and 38 are the size in pixels of the picture
    }
    
    
    void Ciel() {
        //draw the sky
    
        noStroke();
        rectMode(CORNERS);
    
        for  (int i = 1; i < 600; i = i+10) {
            fill( 49    +i*0.165, 118   +i*0.118, 181  + i*0.075   );
            rect(0, i, 800, i+10);
        }
    }
    
    
    void TraceAvion(float Y, float AngleInclinaison) {
        //draw the plane at given position and angle
    
        noStroke();
        pushMatrix();
        translate(400, Y);
        rotate(radians(AngleInclinaison)); //in degres  ! 
    
    
        /*
        Drawing concept :  ;-)
    
         |\___o__
         ________>     
    
         */
    
        scale(0.5);  //0.2 pas mal
    
        //unless drawing the plane "by hands", just display the stored picture instead. Note that the parameters 2 and 3 are half the picture size, to make sure that the plane rotates in his center.
        image(Plane, -111, -55, 223, 110); // 223 110 : picture size
    
    
    
        popMatrix(); //end of the rotation matrix
    }
    
    //file end`
    
  • The HC-SR04 ultrasonic sensor gives me "null"

    Doing tests I found this on the Arduino side:

    /* How to use the HC-SR04 Ultrasonic Sensor with Arduino 
       Dev: Michalis Vasilakis // Date: 23/7/2015 // www.ardumotive.com */
    
    //Libraries
    #include "Ultrasonic.h"
    
    //Define pins ultrasonic(trig,echo)
    Ultrasonic ultrasonic(A0,A1);
    
    //Variables
    int distance;
    
    
    void setup() {
      Serial.begin(9600);
    
    }
    
    void loop(){
      distance = ultrasonic.distanceRead(CM); //Use 'CM' for centimeters or 'INC' for inches
      //Print distance...
      //Serial.print("objeto a:");
      Serial.print(distance);
      //Serial.println("cm");
    
    }
    

    It seems that the null answer it's because the Serial.print(distance) is not continued by a Serial.println() line.

    I did the tests and it works... but the sent "val" from Arduino acummulate in the serial buffer... like if I demand that if the distance is less than 150cm the program should print "SI", but only one time (that I don't know how to declare it) but every time that the readings are less than 150cm the program prints "SISISI" or "SISISISISISISISI"

    Then, I changed this:

    if (distance <= 150) {
        Serial.println("SI");
        digitalWrite(ledPin, HIGH);
      } else {
        Serial.println("NO");
        digitalWrite(ledPin, LOW);
    }
    

    Because I don't want to see the distance readings, but if an object is inside the limit distance. And it works...BUT! this function-that is inside the serialEvent() void- doesn't works:

    if (val.equals("SI")) {
        video1.stop();
        video2.stop();
        video3.stop();
      } else {
        video1.loop();
        video2.loop();
        video3.loop();
      }
    

    What could be wrong?

    Thanks for reading and any help you could give!

  • The HC-SR04 ultrasonic sensor gives me "null"

    Hi, programmers. I have asked many questions about an art project that I'm making, but in different threads. This could be the fifth(?) but here I go...again. The thing is that I'm having troubles with my sensor and the response in Processing. I found the way to stablish communication between the two programs (Arduino and Processing) but when I wanted to execute an "if" statement the sensor doesn't work and gives me the "null" answer. It's a problem with the code in both programs or just the sensor?

    Thanks in advance!

    Here are the both codes:

    Arduino

    /* How to use the HC-SR04 Ultrasonic Sensor with Arduino 
       Dev: Michalis Vasilakis // Date: 23/7/2015 // www.ardumotive.com */
    
    //Libraries
    #include "Ultrasonic.h"
    
    //Define pins ultrasonic(trig,echo)
    Ultrasonic ultrasonic(A0,A1);
    
    //Variables
    int distance;
    int ledPin = 13;
    
    void setup() {
      Serial.begin(9600);
      pinMode (ledPin, OUTPUT);
    }
    
    void loop(){
      distance = ultrasonic.distanceRead(CM); //Use 'CM' for centimeters or 'INC' for inches
      //Print distance...
      if (distance <= 150) {
        Serial.print("SI");
        digitalWrite(ledPin, HIGH);
      } else {
        Serial.print(distance);
        digitalWrite(ledPin, LOW);
      }
    }
    

    Processing

    import processing.serial.Serial;
    import processing.video.*;
    
    Serial myPort;
    String val;   
    Movie video1, video2, video3;
    
    
    
    void setup() {
      fullScreen(SPAN);
      background(0);
      video1 = new Movie(this, "estas ahi.mp4");
      video2 = new Movie(this, "estas lejos.mp4");
      video3 = new Movie(this, "me gustaria estar aqui.mp4");
      video1.loop();
      video2.stop();
      video3.stop();
      String portName = Serial.list()[0];
      myPort = new  Serial(this, portName, 9600);
      myPort.bufferUntil('\n');
    }
    
    void serialEvent(final Serial s) {
      val = s.readString().trim();
      if (val.equals("SI")) {
        video1.stop();
        video2.loop();
        video3.loop();
      } else {
        video1.loop();
        video2.stop();
        video3.stop();
      }
    }
    
    
    void draw() {
      println(val);
      image(video1,320,120,640,480);
      image(video2,1600,200,640,480);
      image(video3,2880,235,640,480);
    
    } 
    
    void movieEvent(Movie video) {
      video.read();
    }
    
  • using fullScreen() to play videos on three different monitors

    Hi there. I'm trying to play three different videos in three different monitors for an art project. I'm using three LED TVs which I set them in 1280x720 pixels each. The code (and the project) includes an ultrasonic sensor that allows to play or stop the videos, but the main issue is that I can't use the fullScreen(P2D, SPAN); function(?). It gaves me the "Framebuffer objects are not supported by this hardware (or driver)..." error. What can I do?!. I searched for info but I didn't find anything. So...If you remember any thread or info or a past project with this issue, please comment

    Thank you thank you thank you!!

    Here's the code:

    //import processing.serial.Serial;
    import processing.video.*;
    
    //Serial myPort;
    //String val;   
    Movie video1, video2, video3;
    
    void settings() {
      fullScreen(P2D,SPAN);
    }
    
    void setup() {
    
      background(0);
      video1 = new Movie(this, "estas ahi.mp4");
      video2 = new Movie(this, "estas lejos.mp4");
      video3 = new Movie(this, "me gustaria estar aqui.mp4");
      video1.stop();
      video2.loop();
      video3.stop();
      //String portName = Serial.list()[0];
      //myPort = new  Serial(this, portName, 9600);
      //myPort.bufferUntil('\n');
    }
    
    //void serialEvent (Serial myPort) {
      //if (myPort.available() > 0) {
        //val=myPort.readStringUntil('\n');
      //}
    
    //}
    
    //void serialEvent(final Serial s) {
      //val = s.readString().trim();
    //}
    
    void draw() {
      //println(val);
      image(video1,480,320,640,480);
      image(video2,120,0,640,480);
      image(video3,200,0,640,480);
    
    } 
    
    void movieEvent(Movie video) {
      video.read();
    }
    
  • How can I get an indoor location with Arduino?

    Active one, with ultrasonic beacons. Be careful with this advice, I'm a begginer. even if I did a lot of research ;-)

  • How can I get an indoor location with Arduino?

    You need landmarks in your room, ceil is the best place. You need a camera (for passive landmarks) or an ultrasonic (for active landmarks) system to find 3 of them, measure distance to them and, finally, triangulate. First steps are the most difficult ! These systems are expensives, about hundred of euros/usd.

  • How can I scan a plant of a room with Arduino and draw it in Processing?

    I think you should buy something with a better resolution. Ultrasonic sensor detects objects inside a 30° cone !!! There is a cheap (about 40 euros, sorry for currency ;-) ) lidar with 1° resolution. I don't know if I can give its name :-/

  • How can I scan a plant of a room with Arduino and draw it in Processing?

    Is there a goal, or is the goal just to move without bumping into anything?

    Is there a rule about what kind of sensor(s) you can use? Any distance sensor, proximity sensor, or camera? Or have you already chosen one, e.g. a laser sensor, ultrasonic sensor, or camera.

  • Maze Following Robot code

    So I a. Doing a project in my robotics class and my Arduino car robot has to get through the maze . So if the robot sensors sees white it will turn right if the robot sensors see black it will turn left and the ultrasonic on will detect the wall infront of it and stop but I just don't have any codeing experience

  • How to get a Sparkfun Servo Motor to Turn both Backwards and Forwards

    I am working on a maze robot project and I am at the stage where I am testing out my servo motors to make sure they work properly. I am using a Sparkfun ArduMoto Motor Driver Shield kit, which includes two servo motors that I will use for my wheels. The program is not complete yet. I do not have commands to turn left and right, my if statements, and more coding for my 3 ultrasonic sensors, but with the coding I have, I cannot get the motors to turn backwards, only forwards. I tried switching the HIGH and LOW commands for the digitalWrite partsin my Void statements, but that did not work. However, the speed difference from a variable of 100 to 255 in my void loop statement worked. So, it is reading and looping through the code properly, but the direction will not change. If anyone can see a problem or a solution to my coding I would appreciate it.

    Attached is my code so far. (without turn left and right, my if statements, and more coding for my 3 ultrasonic sensors which are not quite needed yet at this point.)

    const int sens_1_echoPin = 4; const int sens_1_trigPin = 5; const int sens_2_echoPin = 6; const int sens_2_trigPin = 7; const int sens_3_echoPin = 8; const int sens_3_trigPin = 9;

    int m1direction = 12; int m2direction = 13; int motor1Speed = 3; int motor2Speed = 11;

    float distance_sens_1; float distance_sens_2; float distance_sens_3; long duration1; long duration2; long duration3;

    void setup() {

    pinMode(sens_1_echoPin, INPUT); pinMode(sens_1_trigPin, OUTPUT); pinMode(sens_2_echoPin, INPUT); pinMode(sens_2_trigPin, OUTPUT); pinMode(sens_3_echoPin, INPUT); pinMode(sens_3_trigPin, OUTPUT);

    pinMode(m1direction, OUTPUT); pinMode(m2direction, OUTPUT); pinMode(motor1Speed, OUTPUT); pinMode(motor2Speed, OUTPUT);

    Serial.begin (9600); }

    void goForward (int duration, int pwm) { digitalWrite (m1direction, HIGH); digitalWrite (m2direction, HIGH); analogWrite (motor1Speed, pwm); analogWrite (motor2Speed, pwm); delay(duration); analogWrite (motor1Speed, 0); analogWrite (motor2Speed, 0); }

    void goBackward (int duration, int pwm) { digitalWrite (m1direction, LOW); digitalWrite (m2direction, LOW); analogWrite (motor1Speed, pwm); analogWrite (motor2Speed, pwm); delay (duration); analogWrite (motor1Speed, 0); analogWrite (motor2Speed, 0); }

    void loop() { digitalWrite; goForward (5000, 100); delay (1000); digitalWrite; goBackward (5000, 255); delay (1000);

  • Set distance value with ultrasonic sensor

    Please format your code. Edit your post (gear on top right side of any of your posts), select your code and hit ctrl+o. Leave an empty line above and below your block of code. Details here: https://forum.processing.org/two/discussion/15473/readme-how-to-format-code-and-text

    You can also check previous relevant posts: https://forum.processing.org/two/search?Search=ultrasonic

    Kf

  • Set distance value with ultrasonic sensor

    I want to set the distance from the ultrasonic sensor. For instance, I want to play a video between 0 and 100 cm. Also I stop this video 100 between 250. But I did not write this code part. Can you help me pls ?? :( (I wrote arduino code but I stuck in processing part )

  • Problem Project Raspberry Pi and Arduino (Video)

    Hello my friends. I need your help please.

    My project is I have the arduino and ultrasonic HC-SR04. I want to help please us. The arduino want to measure the distance and what gives the serial. Communicates with the processing and when the distance is greater than 150cm displays an image, if less playing video. My problem is that I run the processing but the video plays either away or close. Please help me.

    When I first my PC, my project is working with library import processing.video.*; and two codes moviesb[index].stop(); + moviesb[index].stop();. After, I want to run my project on Raspberry Pi. But I had the following problem. When I run my project on Pi, The video doesn't show image. Also, Someone here told me, I install library gohai.glvideo. I installed and I change two code from moviesb[index].stop(); to moviesb[index].dispose(); and from moviesa[index].stop(); to moviesa[index].dispose();. Finally, when I run my project, it doesn't work.

    The error is:

    GLVideo: glcolorconvertelement52: Failed to convert video buffer
    Debugging information: gstglcolorconvertelement.c(218): gst_gl_color_convert_element_prepare_output_buffer (): /GstPlayBin:playbin52/GstPlaySink:playsink/GstBin:vbin/GstBin:bin52/GstGLColorConvertElement:glcolorconvertelement52
    GLVideo: glcolorconvertelement50: Failed to convert video buffer
    Debugging information: gstglcolorconvertelement.c(218): gst_gl_color_convert_element_prepare_output_buffer (): /GstPlayBin:playbin50/GstPlaySink:playsink/GstBin:vbin/GstBin:bin50/GstGLColorConvertElement:glcolorconvertelement50
    GLVideo: qtdemux52: Internal data stream error.
    Debugging information: qtdemux.c(6024): gst_qtdemux_loop (): /GstPlayBin:playbin52/GstURIDecodeBin:uridecodebin52/GstDecodeBin:decodebin52/GstQTDemux:qtdemux52:
    streaming stopped, reason error (-5)
    GLVideo: qtdemux50: Internal data stream error.
    Debugging information: qtdemux.c(6024): gst_qtdemux_loop (): /GstPlayBin:playbin50/GstURIDecodeBin:uridecodebin50/GstDecodeBin:decodebin50/GstQTDemux:qtdemux50:
    streaming stopped, reason error (-5)
    GLVideo: multiqueue50: Internal data stream error.
    Debugging information: gstmultiqueue.c(2307): gst_multi_queue_sink_event (): /GstPlayBin:playbin50/GstURIDecodeBin:uridecodebin50/GstDecodeBin:decodebin50/GstMultiQueue:multiqueue50:
    streaming stopped, reason error (-5)
    GLVideo: glcolorconvertelement51: Failed to convert video buffer
    Debugging information: gstglcolorconvertelement.c(218): gst_gl_color_convert_element_prepare_output_buffer (): /GstPlayBin:playbin51/GstPlaySink:playsink/GstBin:vbin/GstBin:bin51/GstGLColorConvertElement:glcolorconvertelement51
    GLVideo: qtdemux51: Internal data stream error.
    Debugging information: qtdemux.c(6024): gst_qtdemux_loop (): /GstPlayBin:playbin51/GstURIDecodeBin:uridecodebin51/GstDecodeBin:decodebin51/GstQTDemux:qtdemux51:
    streaming stopped, reason error (-5)
    

    Can you help me please?

        import gohai.glvideo.*;
        //import processing.video.*;
        import processing.serial.*; 
        Serial myPort;  
        int val;  
        int index=0; 
        int num=27; 
    
        GLMovie[] moviesa=new GLMovie[num]; 
        GLMovie[] moviesb=new GLMovie[num];
    
    
        boolean execMovie=false;
    
        void setup() {
          size(800, 600, P2D); 
          printArray(Serial.list());
    
          myPort = new Serial(this, Serial.list()[0], 9600); 
    
    
          for (int i=0; i<num; i++)
          {
            moviesa[i]=new GLMovie(this, i+"a"+".mp4");
            moviesb[i]=new GLMovie(this, i+"b"+".mp4");
          }
        }
    
        void movieEvent(GLMovie m) {
    
          moviesa[index].read();
    
          moviesb[index].read();
        }
    
        void draw() {
          if (myPort.available() > 0) 
          { 
            val = myPort.read();
          }  
          println(val);  
          delay(1);
    
          if (execMovie==false)
          {
            if (val==0) {
              index=(int)random(num);
            }
            execMovie=!execMovie;
          }
    
          if (execMovie==true) {
            if (val==0) {      
              moviesb[index].dispose(); //moviesb[index].stop();  
              moviesa[index].play();
              image(moviesa[index], 0, 0);
            } else {
              moviesa[index].dispose(); //moviesa[index].stop();
              moviesb[index].play();
              image(moviesb[index], 0, 0);
              execMovie=false;
            }
          }
        }