Howdy, Stranger!

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

  • Play a real-time video when a capacitive sensor is touched

    If you want the code in Processing that plays a video on an event (e.g. a keypressed, a sensor, etc.), check out the example sketches that come with the video library for the basics, then change the signal as per capacitive examples.

  • Play a real-time video when a capacitive sensor is touched

    Hello everyone, I am looking forward a method that when I touch the capacitive sensor, it transmits a signal through Arduino to the processing and then triggers the real-time video through webcam (the webcam is open to capture the video). So far, I could apply the Capacitive sensor library to solve the code problem in Arduino, but I totally have no idea how to write the code in processing and build the communication between them. Is there anyone could give me a right direction or advice or relevant posts or tutorial? Thanks a lot in advance. Sorry for my English if there is any mistake.

  • Help needed getting Processing to open video files.

    The code does play a video from the capacitive touch however it doesn't appear to be randomised.

    lines 60, 61 have a hard-coded value in there. is that what you want?

  • Help needed getting Processing to open video files.

    I have attempted at the below code.

    The code does play a video from the capacitive touch however it doesn't appear to be randomised.

    Also when the sensor is released the video pauses instead of disappearing the sound also carries on for some reason.

    import processing.video.*;
    import processing.serial.*;
    
    Movie myMovie[];
    float t0;
    float t;
    int index = 0; 
    
    int threshold = 30;
    
    //PImage [] picArray = new PImage [26];
    
    Serial myPort;
    
    boolean holdImage=false;
    
    int imgIndex;
    
    void setup(){
    
      size (500,500);
    
      myMovie = new Movie[3];
    
      myMovie[0]  = new Movie(this, "1.mov");
      myMovie[1]  = new Movie(this, "2.mov");
    
      myMovie[0].pause();
      myMovie[1].pause();
    
      myPort = new Serial(this, Serial.list()[1], 9600);
      myPort.bufferUntil('\n');
    }
    
    void draw(){
    
      background (255, 255, 255); 
    
      if (holdImage){ 
        myMovie[index].read();
      }  
      image(myMovie[index], 0, 0);  
    
    }
    
    void serialEvent(Serial myPort){
    
      String inString = myPort.readStringUntil('\n');
    
      if (inString != null){
    
        inString = trim (inString);
        float[] touches = float (split(inString, ","));
    
        if (touches.length >=1) {
          int touch1Value = touches[0] >= threshold ? 1 : 0;
    
          if (touch1Value == 1) {
            if (holdImage == false) {
              myMovie[1].play();
              index = 1;
              holdImage=true;
            }
          } else {
            holdImage=false;
          }
        }
      }
    }
    
  • Help needed getting Processing to open video files.

    Try this

    https://forum.processing.org/two/discussion/4333/how-can-i-get-multiple-videos-to-play-one-after-another-and-triggered-by-specific-keys

    It is important you play the basic movies first. You need to figure out where to place your movie files, to become familiar with Processing and this is an important step so to be able to use it with your capacitive sensor project.

    Kf

  • Help please - Utilising Capacitive Sensor & Images

    Hello,

    As it stands this code pics one randomised image from my data folder, whenever a capacitive sensor is held down.

    I am wanting to replace these images with video files however, I am not sure how to do this.

    Any help would be greatly appreciated!

    import processing.serial.*;
    
    int threshold = 30; 
    PImage [] picArray = new PImage [26]; 
    Serial myPort;
    
    boolean holdImage=false;
    int imgIndex;
    
    void setup() {
      size (500, 500);
    
      for (int i=0; i<picArray.length; i++)
        picArray[i]=loadImage(i + ".png");
    
      myPort = new Serial(this, Serial.list()[1], 9600);
      myPort.bufferUntil('\n');
    }
    
    
    void draw() {
    
      background (255, 255, 255); 
      if (holdImage==true) { 
        image(picArray[imgIndex], 0,0);
      }
    }
    
    
    void serialEvent(Serial myPort) {
    
      String inString = myPort.readStringUntil('\n');
    
      if (inString != null) {
    
        inString = trim (inString);
        float[] touches = float (split(inString, ","));
    
        if (touches.length >=1) {
          int touch1Value = touches[0] >= threshold ? 1: 0;
    
          if (touch1Value == 1) {
            if (holdImage == false) {
              imgIndex=int(random(picArray.length));
              holdImage=true;
            }
          } else
            holdImage=false;  //RELEASE holder so to detect next usr press event
        }
      }
    }
    
  • play a random list of videos by keypress, exhaust

    Hello,

    As it stands this code pics one randomised image from my data folder, whenever a capacitive sensor is held down.

    I am wanting to replace these images with video files however, I am not sure how to do this.

    Any help would be greatly appreciated!

    import processing.serial.*;
    
    int threshold = 30; 
    PImage [] picArray = new PImage [26]; 
    Serial myPort;
    
    boolean holdImage=false;
    int imgIndex;
    
    void setup() {
      size (500, 500);
    
      for (int i=0; i<picArray.length; i++)
        picArray[i]=loadImage(i + ".png");
    
      myPort = new Serial(this, Serial.list()[1], 9600);
      myPort.bufferUntil('\n');
    }
    
    
    void draw() {
    
      background (255, 255, 255); 
      if (holdImage==true) { 
        image(picArray[imgIndex], 0,0);
      }
    }
    
    
    void serialEvent(Serial myPort) {
    
      String inString = myPort.readStringUntil('\n');
    
      if (inString != null) {
    
        inString = trim (inString);
        float[] touches = float (split(inString, ","));
    
        if (touches.length >=1) {
          int touch1Value = touches[0] >= threshold ? 1: 0;
    
          if (touch1Value == 1) {
            if (holdImage == false) {
              imgIndex=int(random(picArray.length));
              holdImage=true;
            }
          } else
            holdImage=false;  //RELEASE holder so to detect next usr press event
        }
      }
    }
    
  • Help needed getting Processing to open video files.

    Unfortunately I'm not very skilled at using processing. I wouldn't know how to play a movie.Yet I want this movie to be started as soon as the capacitive sensor is held down, and stop returning to a white screen when It is finished.

    Any examples would be great, I'll have 26 video labelled 123..etc

  • Help needed getting Processing to open video files.

    hello,

    I am wanting to replace the following code. I have a capacitive touch sensor attached to processing that opens up a random image every time the sensor is held, when the sensor is let go this image disappear.

    I want to essentially replace the image files with 26 short video clips at 25 frame rate. Im not sure how to change this code to make that happen.

    Any help would be great!

    import processing.serial.*;
    
    int threshold = 30; 
    PImage [] picArray = new PImage [26]; 
    Serial myPort;
    
    boolean holdImage=false;
    int imgIndex;
    
    void setup() {
      size (500, 500);
    
      for (int i=0; i<picArray.length; i++)
        picArray[i]=loadImage(i + ".png");
    
      myPort = new Serial(this, Serial.list()[1], 9600);
      myPort.bufferUntil('\n');
    }
    
    
    void draw() {
    
      background (255, 255, 255); 
      if (holdImage==true) { 
        image(picArray[imgIndex], 0,0);
      }
    }
    
    
    void serialEvent(Serial myPort) {
    
      String inString = myPort.readStringUntil('\n');
    
      if (inString != null) {
    
        inString = trim (inString);
        float[] touches = float (split(inString, ","));
    
        if (touches.length >=1) {
          int touch1Value = touches[0] >= threshold ? 1: 0;
    
          if (touch1Value == 1) {
            if (holdImage == false) {
              imgIndex=int(random(picArray.length));
              holdImage=true;
            }
          } else
            holdImage=false;  //RELEASE holder so to detect next usr press event
        }
      }
    }
    
  • Bare Conductive TouchBoard Arduino Input for Processing

    hi, I've tried my best to find out how to get the electrodes on my TouchBoard to work as inputs for Processing. There's a lot about other Arduino hardware bits but nothing about the TouchBoard.
    It has 12 electrodes so I'd need 12 different inputs. I could change it to a MIDI input and work it that way, but I want to keep the capacitive sensing tech, so that would be a final option.
    I've looked at Arduino examples on Processing but none are particularly helpful. Eventually I'd like to implement graphics and sound but I can't even work out how to create an input for the electrodes. Here is an Arduino input example to go from:

    import processing.serial.*;

    import cc.arduino.*;

    Arduino arduino;

    color off = color(4, 79, 111);
    color on = color(84, 145, 158);

    void setup() {
    size(470, 280);

    // Prints out the available serial ports.
    println(Arduino.list());
    // Modify this line, by changing the "0" to the index of the serial
    // port corresponding to your Arduino board (as it appears in the list
    // printed by the line above).
    //arduino = new Arduino(this, Arduino.list()[0], 57600);
    // Alternatively, use the name of the serial port corresponding to your
    // Arduino (in double-quotes), as in the following line.
    arduino = new Arduino(this, "/dev/tty.usbmodem1421", 57600);
    // Set the Arduino digital pins as inputs.
    for (int i = 0; i <= 13; i++)
    arduino.pinMode(i, Arduino.INPUT);
    }

    void draw() {
    background(off);
    stroke(on);
    // Draw a filled box for each digital pin that's HIGH (5 volts).
    for (int i = 0; i <= 13; i++) {
    if (arduino.digitalRead(i) == Arduino.HIGH)
    fill(on);
    else
    fill(off);
    rect(420 - i * 30, 30, 20, 20);
    }

    // Draw a circle whose size corresponds to the value of an analog input.
    noFill();
    for (int i = 0; i <= 5; i++) {
    ellipse(280 + i * 30, 240, arduino.analogRead(i) / 16, arduino.analogRead(i) / 16);
    }
    }

    This code doesn't do anything too exciting, but I can give other examples of other code I'm working on and trying to implement if it's needed.

  • Trouble using capacitive sensor in Processing!

    I am also trying to make a capacitive sensor display a random image each time my sensor is held down.

    I have added all the images I want to be included in this randomisation, however when my sensor is held down it skips constantly through all of my images when I infect just want one to be displayed at a time.

    The key thing I want to keep is the fact that the sensor has to be held down and not pressed.

    Here is my Processing code altered:

    import processing.serial.*;
    
    int touch1Value = 0;
    
    int threshold = 30;
    
    PImage p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25;
    PImage [] picArray = new PImage [26];
    
    Serial myPort;
    
    void setup(){
    
      background (255,255,255);
    
      size (500,500);
    
      myPort = new Serial(this, Serial.list()[1], 9600);
    
      myPort.bufferUntil('\n');
    
      p0 = loadImage("0.png");
      p1 = loadImage("1.png");
      p2 = loadImage("2.png");
      p3 = loadImage("3.png");
      p4 = loadImage("4.png");
      p5 = loadImage("5.png");
      p6 = loadImage("6.png");
      p7 = loadImage("7.png");
      p8 = loadImage("8.png");
      p9 = loadImage("9.png");
      p10 = loadImage("10.png");
      p11 = loadImage("11.png");
      p12 = loadImage("12.png");
      p13 = loadImage("13.png");
      p14 = loadImage("14.png");
      p15 = loadImage("15.png");
      p16 = loadImage("16.png");
      p17 = loadImage("17.png");
      p18 = loadImage("18.png");
      p19 = loadImage("19.png");
      p20 = loadImage("20.png");
      p21 = loadImage("21.png");
      p22 = loadImage("22.png");
      p23 = loadImage("23.png");
      p24 = loadImage("24.png");
      p25 = loadImage("25.png");
    
      picArray[0] = p0;
      picArray[1] = p1;
      picArray[2] = p2;
      picArray[3] = p3;
      picArray[4] = p4;
      picArray[5] = p5;
      picArray[6] = p6;
      picArray[7] = p7;
      picArray[8] = p8;
      picArray[9] = p9;
      picArray[10] = p10;
      picArray[11] = p11;
      picArray[12] = p12;
      picArray[13] = p13;
      picArray[14] = p14;
      picArray[15] = p15;
      picArray[16] = p16;
      picArray[17] = p17;
      picArray[18] = p18;
      picArray[19] = p19;
      picArray[20] = p20;
      picArray[21] = p21;
      picArray[22] = p22;
      picArray[23] = p23;
      picArray[24] = p24;
      picArray[25] = p25;
    
      imageMode(CENTER);
    }
    
    void draw(){
    
      background (255,255,255);
    
      println("touch1Value:"+touch1Value);
    
      if (touch1Value == 1){
    
      image(picArray[int(random(picArray.length))], 250, 250);
      }
    }
    
    void serialEvent(Serial myPort){
    
      String inString = myPort.readStringUntil('\n');
    
      if (inString != null){
    
        inString = trim (inString);
    
        float[] touches = float (split(inString, ","));
    
        if (touches.length >=1){
    
        touch1Value = touches[0] >= threshold ? 1: 0;
        }
      }
    }
    
  • Help please - Utilising Capacitive Sensor & Images

    Hello,

    I am trying to make a capacitive sensor display a random image each time my sensor is held down.

    I have added all the images I want to be included in this randomisation, however when my sensor is held down it skips constantly through all of my images when I infect just want one to be displayed at a time.

    The key thing I want to keep is the fact that the sensor has to be held down and not pressed.

    I'd greatly appreciate any help.

    Here is my Arduino code:

    #include <CapacitiveSensor.h>
    
    CapacitiveSensor   cs_4_2 = CapacitiveSensor(4,2);             
    
    void setup(){
    
      cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF);     
      Serial.begin(9600);
    }
    
    void loop(){
    
      long start = millis();
      long total1 =  cs_4_2.capacitiveSensor(30);
    
      Serial.println(total1); 
    
    
      delay(10);                              
    } 
    

    Here is my Processing code:

    import processing.serial.*;
    
    int touch1Value = 0;
    
    int threshold = 30;
    
    PImage p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25;
    PImage [] picArray = new PImage [26];
    
    Serial myPort;
    
    void setup(){
    
      background (255,255,255);
    
      size (500,500);
    
      myPort = new Serial(this, Serial.list()[1], 9600);
    
      myPort.bufferUntil('\n');
    
      p0 = loadImage("0.png");
      p1 = loadImage("1.png");
      p2 = loadImage("2.png");
      p3 = loadImage("3.png");
      p4 = loadImage("4.png");
      p5 = loadImage("5.png");
      p6 = loadImage("6.png");
      p7 = loadImage("7.png");
      p8 = loadImage("8.png");
      p9 = loadImage("9.png");
      p10 = loadImage("10.png");
      p11 = loadImage("11.png");
      p12 = loadImage("12.png");
      p13 = loadImage("13.png");
      p14 = loadImage("14.png");
      p15 = loadImage("15.png");
      p16 = loadImage("16.png");
      p17 = loadImage("17.png");
      p18 = loadImage("18.png");
      p19 = loadImage("19.png");
      p20 = loadImage("20.png");
      p21 = loadImage("21.png");
      p22 = loadImage("22.png");
      p23 = loadImage("23.png");
      p24 = loadImage("24.png");
      p25 = loadImage("25.png");
    
      picArray[0] = p0;
      picArray[1] = p1;
      picArray[2] = p2;
      picArray[3] = p3;
      picArray[4] = p4;
      picArray[5] = p5;
      picArray[6] = p6;
      picArray[7] = p7;
      picArray[8] = p8;
      picArray[9] = p9;
      picArray[10] = p10;
      picArray[11] = p11;
      picArray[12] = p12;
      picArray[13] = p13;
      picArray[14] = p14;
      picArray[15] = p15;
      picArray[16] = p16;
      picArray[17] = p17;
      picArray[18] = p18;
      picArray[19] = p19;
      picArray[20] = p20;
      picArray[21] = p21;
      picArray[22] = p22;
      picArray[23] = p23;
      picArray[24] = p24;
      picArray[25] = p25;
    
      imageMode(CENTER);
    }
    
    void draw(){
    
      background (255,255,255);
    
      println("touch1Value:"+touch1Value);
    
      if (touch1Value == 1){
    
      image(picArray[int(random(picArray.length))], 250, 250);
      }
    }
    
    void serialEvent(Serial myPort){
    
      String inString = myPort.readStringUntil('\n');
    
      if (inString != null){
    
        inString = trim (inString);
    
        float[] touches = float (split(inString, ","));
    
        if (touches.length >=1){
    
        touch1Value = touches[0] >= threshold ? 1: 0;
        }
      }
    }
    
  • Trouble using capacitive sensor in Processing!

    Hello,

    I'm novice at using Processing.

    In my code I want to change the background to white when the capacitive sensor is held down, and then back to black when the sensor is released.

    I have attempted at writing this code in both capacitive sensor code in Arduino, however when I run my code in Processing nothing is shown or changes.

    Any help would be greatly appreciated.

    MY ARDUINO CODE IS BELLOW

    #include <CapacitiveSensor.h>
    
    CapacitiveSensor   cs_4_2 = CapacitiveSensor(4,2);             
    
    void setup(){
    
      cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF);     
      Serial.begin(9600);
    }
    
    void loop(){
    
      long start = millis();
      long total1 =  cs_4_2.capacitiveSensor(30);
    
      Serial.println(total1); 
      Serial.print(",");                
    
      delay(10);                              
    }
    

    MY PROCESSING CODE IS BELLOW

    import processing.serial.*;
    
    int touch1Value = 0;
    
    int threshold = 30;
    
    Serial myPort;
    
    void setup(){
    
      size (500,500);
    
      myPort = new Serial(this, Serial.list()[1], 9600);
    
      myPort.bufferUntil('\n');
    }
    
    void draw(){
    
      background (0);
    
      println("touch1Value:"+touch1Value);
    
      if (touch1Value == 1){
    
        background (255,255,255);
      }
    }
    
    void serialEvent(Serial myPort){
    
      String inString = myPort.readStringUntil('\n');
    
      if (inString != null){
    
        inString = trim (inString);
    
        float[] touches = float (split(inString, ","));
    
        if (touches.length >=1){
    
          touch1Value = touches[0] >= threshold ? 1: 0;
        }
      }
    }
    
  • Capacitive Sensor Within Processing

    Hello,

    I'm novice at using Processing.

    In my code I want to change the background to white when the capacitive sensor is held down, and then back to black when the sensor is released.

    I have attempted at writing this code in both capacitive sensor code in Arduino, however when I run my code in Processing nothing is shown or changes.

    Any help would be greatly appreciated.

    MY ARDUINO CODE IS BELLOW

    #include <CapacitiveSensor.h>
    
    CapacitiveSensor   cs_4_2 = CapacitiveSensor(4,2);             
    
    void setup(){
    
      cs_4_2.set_CS_AutocaL_Millis(0xFFFFFFFF);     
      Serial.begin(9600);
    }
    
    void loop(){
    
      long start = millis();
      long total1 =  cs_4_2.capacitiveSensor(30);
    
      Serial.println(total1); 
      Serial.print(",");                
    
      delay(10);                              
    }
    

    MY PROCESSING CODE IS BELLOW

    import processing.serial.*;
    
    int touch1Value = 0;
    
    int threshold = 30;
    
    Serial myPort;
    
    void setup(){
    
      size (500,500);
    
      myPort = new Serial(this, Serial.list()[1], 9600);
    
      myPort.bufferUntil('\n');
    }
    
    void draw(){
    
      background (0);
    
      println("touch1Value:"+touch1Value);
    
      if (touch1Value == 1){
    
        background (255,255,255);
      }
    }
    
    void serialEvent(Serial myPort){
    
      String inString = myPort.readStringUntil('\n');
    
      if (inString != null){
    
        inString = trim (inString);
    
        float[] touches = float (split(inString, ","));
    
        if (touches.length >=1){
    
          touch1Value = touches[0] >= threshold ? 1: 0;
        }
      }
    }
    
  • [Processing] Working with sensors

    @Allycia --

    How did you use the Capacitif capacitive sensors with Raspberry Pi and Pure Data? Did you have the Raspberry Pi send messages, like MIDI or OSC, over a wireless or network cable, and then have a desktop machine running Pure Data listen for them?

    Explain more about the setup you have already used and know how to implement with the R.Pi -- you can probably use the same setup with Processing, and this will make the problem easier (your Raspberry Pi will be the same, and only Processing will change).

  • [Processing] Working with sensors

    Hey, sorry for the delay and also thank you for your answer.

    The capacitive sensor is that thing : http://hpics.li/d25c5b3. It's a Raspberry Pi card, on which we have to connect these capacitive sensors.

    With Pure Data, we used the same equipment. I'm totally lost with Processing, even though it's quite the same thing.

    Some people told me to use Serial library, but even with this library, I don't understand how to make this work, the codes we have to write seem to be difficult, I don't even know where to begin.