• I am trying to control a video with the arduino ping sensor and the serial in watcher, but is not working I don't know what I am doing wrong.  I have a code for multiple connections but I just want to connect one sensor and control the video timeline. How do I configure the serial in watcher? 

    here is the code

    #include <Bridge.h>
    #include <BridgeClient.h>
    #include <BridgeServer.h>
    #include <BridgeSSLClient.h>
    #include <BridgeUdp.h>
    #include <Console.h>
    #include <FileIO.h>
    #include <HttpClient.h>
    #include <Mailbox.h>
    #include <Process.h>
    #include <YunClient.h>
    #include <YunServer.h>

    /// PROFESSOR PAULO:
    /// CONFIGURE AQUI AS PORTAS QUE ESTARAO ATIVAS
    /// USE: 1 = ATIVA | 0 = INATIVA

    /// SENSORES SONAR
    int ativosonar1 = 0;
    int ativosonar2 = 0;
    int ativosonar3 = 0;
    int ativosonar4 = 0;
    /// SENSORES PING
    int ativoping1 = 1;  
    int ativoping2 = 0;
    int ativoping3 = 0;
    int ativoping4 = 0;
    /// 

    // SONAR :: CONEXOES DE CADA SENSOR NO ARDUINO
    int pwPin1 = 12; // Ex: PINO 2 DO ARDUINO
    int pwPin2 = 3;
    int pwPin3 = 4;
    int pwPin4 = 5;

    // PING :: CONEXOES DE CADA SENSOR NO ARDUINO
    int pingPin1 = 11;
    int pingPin2 = 7;
    int pingPin3 = 8;
    int pingPin4 = 9;

    //variables needed to store values
    long pulse, inches, cm;
    int val1;
    int val2;
    int val3;
    int val4;

    int var=0;
    int var1=0;
    int val;  //Declare variables. any words are fine.
    int ana = 0; // Value must be same as a number of the analog pin

    void setup()
    {
      
    pinMode(pwPin1, INPUT);
    pinMode(pwPin2, INPUT);  
    pinMode(pwPin3, INPUT);  
    pinMode(pwPin4, INPUT);

    Serial.begin(9600); //Setup serial speed (it is important in a later step)

    }
    void loop()
    {
      
      // establish variables for duration of the ping, 
      // and the distance result in inches and centimeters:
      long duration, inches, cm;
      

      //***************************
      // SONAR #1
      //***************************

    if (ativosonar1==1) {

    //Used to read in the pulse that is being sent by the MaxSonar device.
    //Pulse Width representation with a scale factor of 147 uS per Inch.
    pulse = pulseIn(pwPin1, HIGH); //147uS per inch 
    inches = pulse/147; //change inches to centimetres 
    cm = inches * 2.54;

    // SEND TO ISADORA

    val1 = cm;
    //Serial.print("banana");
    Serial.print(1,DEC); // discuss in later
    Serial.print(val1); //Send a value to computer.
    Serial.println(); //Send a value to eom

    Serial.println("-----------");

    delay(50);

    } //if

      //***************************
      // SONAR #2
      //***************************

    if (ativosonar2==1) {

    //Used to read in the pulse that is being sent by the MaxSonar device.
    //Pulse Width representation with a scale factor of 147 uS per Inch.
    pulse = pulseIn(pwPin2, HIGH); //147uS per inch 
    inches = pulse/147; //change inches to centimetres 
    cm = inches * 2.54;

    // SEND TO ISADORA

    val2 = cm;
    Serial.print(2,DEC); // discuss in later
    Serial.print(val2); //Send a value to computer.
    Serial.println(); //Send a value to eom

    Serial.println("-----------");

    /* UBCOMMENT FOR DEBUG
    Serial.print(pulse); 
    Serial.print("uS, "); 
    Serial.print(inches); 
    Serial.print("in, "); 
    Serial.print(cm); 
    Serial.print("cm"); 
    Serial.println();
    */

    delay(50);

    } // if

      //***************************
      // SONAR #3
      //***************************

    if (ativosonar3==1) {

    //Used to read in the pulse that is being sent by the MaxSonar device.
    //Pulse Width representation with a scale factor of 147 uS per Inch.
    pulse = pulseIn(pwPin3, HIGH); //147uS per inch 
    inches = pulse/147; //change inches to centimetres 
    cm = inches * 2.54;

    // SEND TO ISADORA

    val3 = cm;
    Serial.print(3,DEC); // discuss in later
    Serial.print(val3); //Send a value to computer.
    Serial.println(); //Send a value to eom

    Serial.println("-----------");

    /* UBCOMMENT FOR DEBUG
    Serial.print(pulse); 
    Serial.print("uS, "); 
    Serial.print(inches); 
    Serial.print("in, "); 
    Serial.print(cm); 
    Serial.print("cm"); 
    Serial.println();
    */

    delay(50);

    } // if

      //***************************
      // SONAR #4   -  DESATIVADO TEMPORARIAMENTE (COMENTADO GERAL)
      //***************************

    if (ativosonar4==1) {

    //Used to read in the pulse that is being sent by the MaxSonar device.
    //Pulse Width representation with a scale factor of 147 uS per Inch.

    //pulse = pulseIn(pwPin4, HIGH); //147uS per inch 
    //inches = pulse/147; //change inches to centimetres 
    //cm = inches * 2.54;

    // SEND TO ISADORA

    //val4 = cm;
    //Serial.print(4,DEC); // discuss in later
    //Serial.print(val4); //Send a value to computer.
    //Serial.println(); //Send a value to eom

    //Serial.println("-----------");

    /* UBCOMMENT FOR DEBUG
    Serial.print(pulse); 
    Serial.print("uS, "); 
    Serial.print(inches); 
    Serial.print("in, "); 
    Serial.print(cm); 
    Serial.print("cm"); 
    Serial.println();
    */

    //delay(50);

    } // if

    ///////////////////
    /// P  I  N  G  ///
    ///////////////////

    if (ativoping1==1) {

    pingPin1 = 11;  // PRIMEIRO SENSOR > DEPOIS FAZER LOOP

      // The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
      // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
      pinMode(pingPin1, OUTPUT);
      digitalWrite(pingPin1, LOW);
      delayMicroseconds(2);
      digitalWrite(pingPin1, HIGH);
      delayMicroseconds(5);
      digitalWrite(pingPin1, LOW);
      
      
      pinMode(pingPin1, OUTPUT);
      digitalWrite(pingPin1, LOW);
      delayMicroseconds(2);
      digitalWrite(pingPin1, HIGH);
      delayMicroseconds(5);
      digitalWrite(pingPin1, LOW);
      

      // The same pin is used to read the signal from the PING))): a HIGH
      // pulse whose duration is the time (in microseconds) from the sending
      // of the ping to the reception of its echo off of an object.
      pinMode(pingPin1, INPUT);
      duration = pulseIn(pingPin1, HIGH);

      // convert the time into a distance
      inches = microsecondsToInches(duration);
      cm = microsecondsToCentimeters(duration);
      
      Serial.print(inches);
      Serial.print("in, ");
      Serial.print(cm);
      Serial.print("cm");
      Serial.println();
     
      

      delay(50);
      
      val = cm ;

    val = analogRead(ana); //get data from analog
    //val = 123;
    //Serial.print("miau");
    Serial.print(5,DEC); // discuss in later
    Serial.print(val); //Send a value to computer.
    Serial.println(); //Send a value to eom

    Serial.println("-----------");

    } //if

    if (ativoping2==1) {

    pingPin2 = 7;  // SEGUNDO SENSOR > DEPOIS FAZER LOOP

      // The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
      // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
      pinMode(pingPin2, OUTPUT);
      digitalWrite(pingPin2, LOW);
      delayMicroseconds(2);
      digitalWrite(pingPin2, HIGH);
      delayMicroseconds(5);
      digitalWrite(pingPin2, LOW);
      
      
      pinMode(pingPin1, OUTPUT);
      digitalWrite(pingPin2, LOW);
      delayMicroseconds(2);
      digitalWrite(pingPin2, HIGH);
      delayMicroseconds(5);
      digitalWrite(pingPin2, LOW);
      

      // The same pin is used to read the signal from the PING))): a HIGH
      // pulse whose duration is the time (in microseconds) from the sending
      // of the ping to the reception of its echo off of an object.
      pinMode(pingPin2, INPUT);
      duration = pulseIn(pingPin2, HIGH);

      // convert the time into a distance
      inches = microsecondsToInches(duration);
      cm = microsecondsToCentimeters(duration);
      
      /*Serial.print(inches);
      Serial.print("in, ");
      Serial.print(cm);
      Serial.print("cm");
      Serial.println();
     
      */

      delay(50);
      
      val = cm ;

    //val = analogRead(ana); //get data from analog
    //val = 123;
    Serial.print(6,DEC); // discuss in later
    Serial.print(val); //Send a value to computer.
    Serial.println(); //Send a value to eom

    Serial.println("-----------");

    } // if

    if (ativoping3==1) {

    pingPin3 = 8;  // TERCEIRO SENSOR > DEPOIS FAZER LOOP

      // The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
      // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
      pinMode(pingPin3, OUTPUT);
      digitalWrite(pingPin3, LOW);
      delayMicroseconds(2);
      digitalWrite(pingPin3, HIGH);
      delayMicroseconds(5);
      digitalWrite(pingPin3, LOW);
      
      
      pinMode(pingPin3, OUTPUT);
      digitalWrite(pingPin3, LOW);
      delayMicroseconds(2);
      digitalWrite(pingPin3, HIGH);
      delayMicroseconds(5);
      digitalWrite(pingPin3, LOW);
      

      // The same pin is used to read the signal from the PING))): a HIGH
      // pulse whose duration is the time (in microseconds) from the sending
      // of the ping to the reception of its echo off of an object.
      pinMode(pingPin3, INPUT);
      duration = pulseIn(pingPin3, HIGH);

      // convert the time into a distance
      inches = microsecondsToInches(duration);
      cm = microsecondsToCentimeters(duration);
      
      /*Serial.print(inches);
     

    Serial.print("in, ");
      Serial.print(cm);
      Serial.print("cm");
      Serial.println();
     
      */

      delay(50);
      
      val = cm ;

    //val = analogRead(ana); //get data from analog
    //val = 123;
    Serial.print(7,DEC); // discuss in later
    Serial.print(val); //Send a value to computer.
    Serial.println(); //Send a value to eom

    Serial.println("-----------");

    } // if

    if (ativoping4==1) {

    pingPin4 = 9;  // QUARTO SENSOR > DEPOIS FAZER LOOP

      // The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
      // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
      pinMode(pingPin4, OUTPUT);
      digitalWrite(pingPin4, LOW);
      delayMicroseconds(2);
      digitalWrite(pingPin4, HIGH);
      delayMicroseconds(5);
      digitalWrite(pingPin4, LOW);
      
      
      pinMode(pingPin4, OUTPUT);
      digitalWrite(pingPin4, LOW);
      delayMicroseconds(2);
      digitalWrite(pingPin4, HIGH);
      delayMicroseconds(5);
      digitalWrite(pingPin4, LOW);
      

      // The same pin is used to read the signal from the PING))): a HIGH
      // pulse whose duration is the time (in microseconds) from the sending
      // of the ping to the reception of its echo off of an object.
      pinMode(pingPin4, INPUT);
      duration = pulseIn(pingPin4, HIGH);

      // convert the time into a distance
      inches = microsecondsToInches(duration);
      cm = microsecondsToCentimeters(duration);
      
      /*Serial.print(inches);
      Serial.print("in, ");
      Serial.print(cm);
      Serial.print("cm");
      Serial.println();
     
      */

      delay(50);
      
      val = cm ;

    //val = analogRead(ana); //get data from analog
    //val = 123;
    Serial.print(8,DEC); // discuss in later
    Serial.print(val); //Send a value to computer.
    Serial.println(); //Send a value to eom

    Serial.println("-----------");

    } //if

    }

    long microsecondsToInches(long microseconds)
    {
      // According to Parallax's datasheet for the PING))), there are
      // 73.746 microseconds per inch (i.e. sound travels at 1130 feet per
      // second).  This gives the distance travelled by the ping, outbound
      // and return, so we divide by 2 to get the distance of the obstacle.
      // See: http://www.parallax.com/dl/doc...
      return microseconds / 74 / 2;
    }

    long microsecondsToCentimeters(long microseconds)
    {
      // The speed of sound is 340 m/s or 29 microseconds per centimeter.
      // The ping travels out and back, so to find the distance of the
      // object we take half of the distance travelled.
      return microseconds / 29 / 2;
    }

  • Tech Staff

    @catoyo said:

    I am trying to control a video with the arduino ping sensor and the serial in watcher, but is not working I don't know what I am doing wrong.  I have a code for multiple connections but I just want to connect one sensor and control the video timeline. How do I configure the serial in watcher? 

    Unfortunately, serial data is not my forte, but I do know where to look for information about it.

    If you double click the Serial In Watcher, you'll get the dialog to edit the code for it. At the bottom left is a help button that links to some very useful information.

    If that doesn't get you up and running, here are all the pages of the Manual for Isadora 3 relevant to working with serial data


  • @catoyo this might help you:

    https://github.com/eighteight/MeyerholdTheatreCenter2014/tree/master/Exercise4-UltraSound-Isadora

    It is a repo from @eight that has a good working example. Basically the serial data is sent as a string from arduino using this funciton:

    So Isadora would recieve something like this 1|44 the two numbers are separated by the | sign. This allows them to be separated by Isadoras serial in watcher.

    Inside the serial watcher you can find this:

    route:int=2 digits "|" value:int=4 digits

    That will create 2 outputs, 1 called route and 1 called value. The route can have 2 digits (0-99) and the value can have 4 (0, 9999).

    It is a good repo if you want to start with some code that works.

    void sendValueToIzzy(int route, int value){
      Serial.print(route);
       Serial.print('|');
      Serial.print(value);
      Serial.print(' '); 
    }
  • Beta Platinum

    @catoyo


    Hi, If you have a three pin sensor the following Arduino setup is likely to work. If the sensor indicates 5v, it requires the Arduino code to be uploaded to a board with 5v pin like the UNO - which is what I have just tested it on using a 3 pin Pulse Sensor. The pin out is GND, 5V and the data / SIG (signal) pin is A0. If it is a digital pmw then change the signal to a digital pin on the Arduino board.

    With the sensor correctly wired to the Arduino attach it to your computer using a USB cable. Start up Arduino.IDE and upload the code at the end of this post to your board of choice. Start up Isadora and from the Communication menu select the Serial Port Setup... In the dialog that opens go to Port 1 and in the pop-up choose the usbmodem14424 or similar as the Device. The Arduino code has a speed set to 9600 so set the speed of Port 1 to match. Leave the other values unchanged from the default. OK the changes and close the dialog. If the usb serial connection is not available you can use the button 'Detect Serial Ports' on the bottom left of the dialog box. When the dialog has closed go back to the Communication menu and check 'Enable Serial Ports'.

    In the Isadora patch you want a 'Serial In Watcher - Text' actor with the parameters- 1: port, on: enable, 10: eom char. Inside the "Serial In Watcher' is this parser string: 

    "Pulse Data: " pulse_sensor:float=4.#

    You can also look at the Windows/Show Monitor to see if the data stream is being received.

    Following is the Arduino code:

    int Press = A2;
    int PressCapture;
    int PulseSensor = A0;
    int DelayTime = 25;
    int PulseCapture;
    void setup(void) {
      // initialize serial communication at 9600 bits per second:
      Serial.begin(9600);
      // while the serial stream is not open, do nothing:
       while (!Serial) ;
    }
    void loop(void) {
      PulseCapture = analogRead(PulseSensor);
      PressCapture = analogRead(Press);
      Serial.print("Pulse Data: ");
      Serial.println(PulseCapture);
      Serial.print("Press Data: ");
      Serial.println(PressCapture);
      delay(DelayTime); 
    }
     

    best wishes

    Russell