Howdy, Stranger!

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

  • sending multiple values from processing to arduino

    I have managed to send one value from processing to arduino. (which maps mouseX and lights the respective LED on an LED strip of Neopixels) I went through a lot of forums and tried to send MOuse Position(2 values ) from processing to arduino .. By trying to seperate the numbers using substring and toInt ... But then the programm doesn't seem to be working.
    can anyone share an simple example that sends and recieves X and Y values

  • Error, disabling serialEvent()

    The full message I am getting is: Error, disabling serialEvent() for /dev/cu.usbmodem2574541 null

    The sketch will get the data one time than it hangs on this message.

    Here is my code; I am getting the data from an arduino teensy 3.5 Please help.

    Thanks

    import processing.serial.*; Serial port; int BaseEncGlobal; int ElbowEncGlobal; int ShoEncGlobal; int VertRotEnc; int HorRotEnc; int GripEncGlobal;

    double X_axis; double Y_axis; double Z_axis; double GripAngle;

    String data; boolean newData = false;

    PFont font;

    void setup() { size(1280,800); //port = new Serial(this, "/dev/cu.usbserial-A50285BI", 115200); port = new Serial(this, "/dev/cu.usbmodem2574541", 115200); port.bufferUntil('\n'); font = loadFont("AgencyFB-Bold-200.vlw"); textFont(font, 40); }

    void draw()

    { if (newData == true) {

    int spaceDown = 55; background(0,0,0); fill(46, 209, 2); text(BaseEncGlobal, 70, spaceDown); fill(0, 102, 153); text(ShoEncGlobal, 70, spaceDown2); fill(0, 102, 153); text(ElbowEncGlobal, 70, spaceDown3); fill(0, 102, 153); text(VertRotEnc, 70, spaceDown4); fill(0, 102, 153); text(HorRotEnc, 70, spaceDown5); fill(0, 102, 153); text( GripEncGlobal, 70, spaceDown*6);

    text(Double.toString(X_axis/10), 270, spaceDown ); newData =false; }

    }

    void serialEvent (Serial port) {

    data = port.readStringUntil('\n'); if (data != null) { data = trim(data);

    int[] nums = int(split(data, ',')); BaseEncGlobal = nums [1]; ShoEncGlobal = nums [2]; ElbowEncGlobal = nums [3]; VertRotEnc = nums [4]; HorRotEnc = nums [5]; GripEncGlobal = nums [6]; X_axis = nums [7]; Y_axis = nums [8]; Z_axis = nums [9]; GripAngle = nums [10]; //println(Double.toString(X_axis/10));

    println(data);

    newData = true; }

    }

    /*

    void serialEvent (Serial port) { data = port.readStringUntil('.'); data = data.substring(0, data.length() - 1);

    // look for the comma between Celcius and Farenheit index = data.indexOf(","); // fetch the C Temp temp_c = data.substring(0, index); // fetch the F Temp //temp_f = data.substring(index+1, index); temp_f = data.substring(1, data.length());

    ElbowEncGlobal =  getValue(data, ',', 2);
    

    } */

  • Reliably send images over net

    @GoToLoop, certainly, "Java's datatype byte is problematic", but it is the only 8-bit datatype that Java has. Communication methods need to use that datatype. I have had some problems trying to send data between sketches, and also trying to send data between Arduino and Processing. You came to help, I'm sorry if I was a bit harsh in my response. I probably should have pointed out your error in a private message, but I guess we both learned something from this. Again, thanks for your help.

  • How can I do headless / virtual screen buffer pixel reading?

    Hi

    I currently have a setup with Processing running on Raspberry Pi, sending artnet messages across multiple universes to some Teensy's to do LED lighting animations using @cansik 's artnet library. I'm running into serious framerate issues - with drawing animations to screen, then reading from screen into a pixel buffer and then sending messages over artnet, it runs at approximately 7fps.

    I know that I can run the whole thing headless, or by not drawing to screen, my fps bumps up to 45-50fps, which is fine, but it limits my ability to make content through creating video or animations and filling my pixel buffer from there. Does anyone know of ways to do this maybe via a virtual screen buffer? The workflow would be create content and read pixels to a pixel buffer from screen during development, and then switch to a virtual buffer when running live.

    Code below. Setting the writeToScreen boolean to false, switches the code to writing directly to the pixel buffer.

    import ch.bildspur.artnet.*;
    import processing.serial.*;
    
    //___________________________
    // setup pattern
    boolean readFromScreen = false;
    boolean writeToScreen = true;
    Pattern patterns[] = {
      new TraceDown(), new TraceDown(), new TraceDown(), new TraceDown(), new FadeTrace(), new TraceDown(), 
      new TraceDown(), new TraceDown(), new TraceDown(), new TraceDown(), new FadeTrace(), new TraceDown(), 
      new TraceDown(), new TraceDown(), new TraceDown()
    };
    
    //___________________________
    // setup artnet 
    ArtNetClient artnet;
    int numUniverse = 15;
    int numChannels = 510;
    byte[] dmxData = new byte[numChannels];
    ArtnetDMX Artnetclass = new ArtnetDMX();
    
    //___________________________
    // stetup serial
    Serial port;  // Create object from Serial class
    String data = "0 0";     // Data received from the serial port
    int[] nums;
    byte[] inBuffer = new byte[4];
    
    int windSpeed;
    int windDir;
    float windSpeedCal;
    
    //___________________________ 
    // setup leds
    int numLeds = 88;
    color led[][] = new color[numChannels/3][numUniverse];
    int size = 2;
    color[][] pixelBuffer = new color[numChannels/3][numUniverse];
    
    //___________________________
    // setup timer
    long[] ellapseTimeMs = new long[numUniverse];
    long[] ellapseTimeMsStartTime = new long[numUniverse];
    float durationMs = 3000;
    boolean direction = true; 
    
    
    //_________________________________________________________
    void setup()
    {
    
      size(300, 80);
      colorMode(HSB, 360, 100, 100);
      textAlign(CENTER, CENTER);
      textSize(20);
    
      // create artnet client without buffer (no receving needed)
      artnet = new ArtNetClient(null);
      artnet.start();
    
      // create port
      //String portName = Serial.list()[0];
      //port = new Serial(this, portName, 2000000);
    }
    
    //_________________________________________________________
    void draw()
    {
      // create color
      int c = color(frameCount % 360, 80, 100);
    
      background(0);
      stroke(0);
    
      //change direction
      if (ellapseTimeMs[0]> durationMs) direction = !direction;
      // choose pattern to run on LED strip
      // int pattern = 0;  
      for (int i = 0; i <numChannels/3; i++) {
        for (int j = 0; j < numUniverse; j++) {
          if (ellapseTimeMs[j]> durationMs) {
            ellapseTimeMsStartTime[j] = 0;
          } else if (direction==true) {
            float position = i/(float)(numChannels/3);
            float remaining = 1.0 - ellapseTimeMs[j]/durationMs;
            if (readFromScreen == false){
              pixelBuffer[i][j] = patterns[j].paintLed(position, remaining, led[i][j]);
            } else {
              led[i][j] = patterns[j].paintLed(position, remaining, led[i][j]);
            }
    
          } else {
            float position = 1.0 - (i/(float)(numChannels/3));
            float remaining = ellapseTimeMs[j]/durationMs;
            if (readFromScreen == false){
              pixelBuffer[i][j] = patterns[j].paintLed(position, remaining, led[i][j]);
            } else {
              led[i][j] = patterns[j].paintLed(position, remaining, led[i][j]);
            }
          }
        }
      }
    
      if (writeToScreen == true) {
        showPattern();
      }
    
      if (readFromScreen == true){
        updatePixelBuffer();
      } 
    
      Artnetclass.updateArtnet(artnet, dmxData, pixelBuffer);
      //oldUpdateArtnet();
    
      updateEllapseTime();
      println(frameRate);
    
      // show values
      //text("R: " + (int)red(c) + " Green: " + (int)green(c) + " Blue: " + (int)blue(c), width-200, height-50);
    }
    
    
    // clock function
    void updateEllapseTime() {
      for (int j = 0; j < numUniverse; j++) {
        if (ellapseTimeMsStartTime[j] == 0) {
          ellapseTimeMsStartTime[j] = millis();
          ellapseTimeMs[j] = 0;
        } else {
          ellapseTimeMs[j] = millis() - ellapseTimeMsStartTime[j];
        }
      }
    }
    
    // storing pixels from screen
    void updatePixelBuffer() {
      for (int i = 0; i < numChannels/3; i++) {
        for (int j = 0; j < numUniverse; j++) {
          // read screen pixels and assign to pixel buffer
          //pixelBuffer[i][j] = get(i*size/2+(size/4), j*size+size/2);
          pixelBuffer[i][j] = get(i*size +size/2, j*size+size/2);
          fill(pixelBuffer[i][j]);
          stroke(pixelBuffer[i][j]);
          rect(50+i, 50+j, 1, 1);
        }
      }
    }
    
    // draw pattern on screen
    void showPattern() {
      for (int i = 0; i < numChannels/3; i++) {
        for (int j = 0; j < numUniverse; j++) {
          // show only pixel buffer if not reading from screen
          if (readFromScreen == false){
              fill(pixelBuffer[i][j]);
            } else {
              fill(led[i][j]);
            }
          rect(i*size+size, j*size+size, size, size);
        }
      }
    }
    
  • how to show multiple data from arduino

    how to read the value from arduino and then i want to displaying that on processing window. This is my arduino code:

          #include <TimerOne.h>            
          #include <PZEM004T.h>
          #include <LiquidCrystal.h>
    
    
          int dutycycle = 0;     // Initailize duty cylce variable as integer data type
          int incomingByte = 0;
          PZEM004T pzem(2,3);  // (RX,TX) connect to TX,RX of PZEM
          IPAddress ip(192,168,1,1);
          LiquidCrystal lcd(12, 11, 4, 5, 6, 7);
    
    
           void setup()               // Setup function
          {
            Serial.begin(9600);
            pinMode (9, OUTPUT);             // set pin 9 as an output pin for pwm
            pinMode (10, OUTPUT);            // set pin 10 as an output pin for pwm
            Timer1.initialize(20000);             // Initailize timer1 time period as 20 milli second (50 Hz frequency)
            TCCR1A = (TCCR1A & 0x0F) | 0xB0 ;             // set pin 10 inverted of pin 9
            pzem.setAddress(ip);
            lcd.begin(16, 2); // lcd rows and columns
           }
    
    
          void loop()              // loop function starts
          { 
          if (Serial.available() > 0)
          {
          incomingByte = Serial.read ();  
          dutycycle = map(incomingByte, 0, 255, 0, 1023);
          Timer1.pwm(9, dutycycle, 20000);            // Timer1.pwm function takes argument as (pin no. , dutycycle , time period)
          Timer1.pwm(10, 1023-dutycycle, 20000);
    
    
          float v = pzem.voltage(ip);
          if (v < 0.0) v = 0.0;
    
          Serial.print(v);Serial.print("V; ");
          lcd.clear();
          lcd.setCursor(0,0);
          lcd.print("V= ");
          lcd.setCursor(2,0);
          lcd.print(v);
    
    
          float i = pzem.current(ip);
          if (i < 0.0) i = 0.0;
    
          Serial.print(i);Serial.print("A; ");
          lcd.clear();
          lcd.setCursor(9,0);
          lcd.print("A= ");
          lcd.setCursor(11,0);
          lcd.print(i);
    
    
          float p = pzem.power(ip);
          if (p < 0.0) p = 0.0;
    
          Serial.print(p);Serial.print("W; ");
          lcd.clear();
          lcd.setCursor(9,1);
          lcd.print("W= ");
          lcd.setCursor(11,1);
          lcd.print(p);
    
    
          float e = pzem.energy(ip);
    
          Serial.print("PF= ");Serial.print((p)/(v*i));
          lcd.setCursor(0,1);
          lcd.print("PF=");
          lcd.setCursor(3,1);
          lcd.print((p)/(v*i));
    
          Serial.println(v);
          Serial.println(i);
          Serial.println(p);
          Serial.println((p)/(v*i));
    
         delay(100);  
         }
         }               // loop function ends
    

    i want to send the value of "v","i","p" and "pf" and show it in processing window, this is my processing code :

          import controlP5.*;
          import processing.serial.*;
    
          ControlP5 cP5;
    
          Serial arduino;
          String val= "0";
    
          void setup() 
          {
          size(800, 550);
          println(Serial.list());
          String portName = Serial.list()[0];
          arduino = new Serial(this, portName, 9600);
    
          cP5 = new ControlP5(this);
          cP5.addSlider("ATUR DUTY CYCLE", 0, 255, 0, 210, 155, 350, 50);
          }
    
          void draw() 
          {
          background(#614DED);
          textSize(20);
          fill(#F5ED00);
          text("PENGENDALIAN INVERTER FULL BRIDGE SATU FASA", 140, 30);
          textSize(20);
          text("SECARA WIRELESS BERBASIS ARDUINO", 200,60);
          text("ARUS", 210, 300);
          text("TEGANGAN", 460, 300);
          text("DAYA", 210, 400);
          text("FAKTOR DAYA", 460, 400);
    
          if (arduino.available() >0){
          delay(100);
          val=arduino.readString();}  
    
          textSize(18);
          fill(#FAFF08);
          text(val, 210 ,330 );
    
          textSize(18);
          fill(#FAFF08);
          text(val, 460, 330);
    
          textSize(18);
          fill(#FAFF08);
          text(val, 210, 430);
    
          textSize(18);
          fill(#FAFF08);
          text(val, 460, 430);
    
          }
    
           void controlEvent(ControlEvent theEvent) {
           if(theEvent.isController()) {
    
           int val = int(theEvent.getController().getValue());
           arduino.write(val);
           } 
           }
    

    Thank you very much

  • 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!!

  • Arduino, Processing, P5js - Project help

    Hi there, Looking for someone with knowledge in Arduino, Processing, P5js who can work with me closely in developing a project. Interested people please get in touch with me for further details. Thank you.

  • Processing and Arduino Jobs

    Do you know where I could apply freelance jobs wherein processing or arduino coding are involved?

  • When will Processing IDE shift to Java 8

    Processing as a "programming language", rather than an actual library, caters more for the artistic folks. :D

    And Processing's already got the 3 most important languages for them covered, and even beyond: $-)

    1. Java as Java & Android Modes: Still the world's most used programming language. C-style syntax. ~O)
    2. JavaScript as both Pjs & p5.js flavors: Literally the Java's syntax deployed to the web! Where most artists wanna show up their works! :bz
    3. Python as both Python Mode & p5py flavors: Earned its place in academics introductory programming courses, due to its clean (no curly brackets) & easier syntax. O:-)

    Of course there are also R as R Mode, Clojure as Quill and Ruby as Ruby-Processing. Maybe more. <:-P
    And similar to Processing we've even got C/C++ as Arduino & openFrameworks. \m/

  • [Argument / Android mode] Processing Android Mode How to succeed

    @SnailPropulsionLabs===

    sorry, i have not seen any examples (from your link) related to wifi, blueTooh or nfc; tell me if i am wrong.

    @Gwak===

  • Stacktrace Question - StringIndexOutOfBoundsException

    Thanks Chrisir. I've already figured that out. Unfortunately it isn't realistic to post my code. I have thousands of lines and multiple threads. I'm also using several libraries and I'm interacting with an Arduino over serial and hundreds of text files. Nobody would be able to duplicate the error with just the code. I've been injecting println commands into the code to try to figure out where the problem is happening but as of yet I haven't been able to pinpoint it. What I was trying to figure out with this question is how to decipher some of the stack trace codes. Specifically, what does 1967 refer to?

  • Serial

    Is it possible to use the serial p5.serialcontrol and a local server to broadcast the data acquired by an Arduino?

  • out of memory error on loadImage() in Draw loop

    Great, thank you for sharing your solution. May I ask why you were calling stop()? I have done arduino and serial stuff before and I didn't call this at all before. Where you following some reference that was advising you to do this?

    Kf

  • Mapping Festival 2018 : WORKSHOPS PROGRAM (Geneva, May 9th-12th 2018)

    The Mapping Festival will take place in Geneva, Switzerland, from May 9th to 12th.

    MAY 9th : Forum Paradigm_Shifts #2 + Opening Party

    MAY 10th : Mapping LAB : WORKSHOPS

    MAY 11th & 12th : Mapping LIVE

    Join leading artists and designers for Mapping LAB, a full day of workshops curated and produced together with CreativeApplications.Net 1, and learn (more) about creative coding, machine learning, augmented reality, synthesizer making, interface prototyping, data visualisation and more.

    WORKSHOPS PROGRAM :

    Network Counter-Surveillance Boot-Camp / Julian Oliver (NZ) Capturing wireless traffic, device tracking, exploiting cellular networks – critical engineer Julian Oliver will provide a primer in network topologies, threat-modelling, and surveillance tactics, and introduce tools and techniques for self-protection.

    TouchDesigner & Live Performance / Markus Heckmann (DE/CA) TouchDesigner Technical Director Markus Heckmann will introduce the powerful visual development platform and present best practices for using it in live performance – from video mixing to generative 2D/3D to MIDI control to projection mapping.

    Rethinking UIs for a Post-Screen Era/ N O R M A L S (FR) Welcome to the N O R M A L S-led Bureau for Anticipated Interfaces, where you will search for human-computer interactions beyond ‘click, type, tap.’ Using Processing and paper, participants will author both a spatial operating system and new digital rituals.

    Visual Programming with Paper.js / Jürg Lehni (CH) Unpacking the anatomy of Bézier paths and vector geometry, artist and designer Jürg Lehni will teach participants how to use the Paper.js scripting framework to generate complex graphics and build dynamic drawing tools that can be used manually or procedurally.

    Processing Oscilloscopes/ Ted Davis (US) Using his recently released XYscope Processing library, media artist Ted Davis will share beginner-friendly creative coding strategies for audio/video synthesis by drawing vector graphics on an analog oscilloscope – a conversion of shape paths into sound.

    Machine Learning for Artists / Gene Kogan (US) Join machine learning authority Gene Kogan for a survey of the rapidly evolving deep generative model landscape. Learn about variational autoencoders and generative adversarial networks, key codebases and artist projects, and tinker with the pix2pix framework.

    Data Visualisation for a Post-Truth World / Lisa Charlotte Rost, Stef Tervelde (DE/NL) An editorial data vis whizz (Bloomberg, NPR, ZEIT Online, Tagesspiegel), Lisa Charlotte Rost will provide a comprehensive data visualization primer that juxtaposes tactics, techniques, and tools used in both the newsroom and data art. Learn how to read, visualize, and plot data!

    Programmable Matter & Photoelasticity / Dana Zelig (IR) Drawing on her research with programmable polymers and textiles, design researcher Dana Zelig will teach participants how to encode behaviours into everyday materials (e.g. plastic) through creative experimentation with photoelasticity.

    Augmented Reality DIY / Raphaël de Courville, Stef Tervelde (FR/NL) The magic of the virtual overlay: creative technologists Raphaël de Courville and Stef Tervelde will introduce mobile Augmented Reality, show how to develop for it using Unity and ARKit, and help participants build their own interactive mobile AR experience.

    Draw (and Play) a Synthesizer / Coralie Gourguechon (FR) Using conductive paint and paper electronics, designer Coralie Gourguechon will demonstrate how to create a variety of (lofi) musical interfaces by simply drawing them. This session includes introductions to electronic prototyping, 555 timers, and sound generation.

    Browser History Matchmaking / Dries Depoorter (BE) Join media artist Dries Depoorter for a fun group experiment in online dating, Google algorithm tweaking, and browser history analysis and learn about today’s web technology in the process. Will you find your perfect match at Mapping? P.S. Results may inform Depoorter’s next artwork.

    Mapping, Mixing, Modulating Light and Video / Gaël Abegg Gauthey (CH) Opening their toolbox of MadMapper, Modul8, and miniMAD, garageCube’s Gaël Abegg Gauthey will demonstrate how to manage, mix, map, and modulate light and video in real-time. Learn how to control LEDs and multi-computer set-ups in installations or on stage.

    Hacking the Human Sensorium / Susanna Hertrich, Daniela Silvestrin (DE/CH) Making the invisible visible: artist Susanna Hertrich and researcher Daniele Silvestrin will reveal the secret world of electromagnetic (EM) fields – and how easily our senses can be tricked. Using EM field detectors and hands-on experiments, participants will prototype sensorial hacks.


    TICKETS : https://etickets.infomaniak.com/shop/d7FHecPkhK/ 1

    INFORMATION TICKETS : https://2018.mappingfestival.com/en/tickets/ 4

    INFORMATION WORKSHOPS : https://2018.mappingfestival.com/en/event/thursday-10-may-2018/

  • save and load Array list

    Can you read data from arduino now...?

  • save and load Array list
      PVector prev = new PVector(-1, -1); 
      int y=50; 
      for (PVector pv : points2) {
    
        if (showText) {
          fill(0, 255, 2); // GREEN 
          // show data
         // text(pv.x, 210, y); 
           text(pv.x, 1080-50, y+410);
           text(pv.y, 1080, y+410);
        }
    
        fill(0, 2, 2); 
        stroke(0, 255, 2); // GREEN 
        float yvalue = map( pv.y, 0,1, 700, 180); // dimensione grafico GREEN
        if (prev.x!=-1) {
          line(80 + pv.x*55, yvalue, // linea grafico verde
            prev.x, prev.y);
    
        }
        noStroke(); 
        ellipse (80 + pv.x*55, yvalue, 4, 4);
        prev = new PVector(80 + pv.x*55, yvalue);
    
        y+=20; //next line
      }//for
    
      if (showText) {
      //  // middle line 
        stroke(0, 255, 2); // GREEN 
        line( 1275-220, 440, 1275-220, 720);// linea divisoria
    
      }
      ////
    }
    
    void showData3() {
      //
      // show data 3
    
      color col3 = color(0, 2, 255); // BLUE 
    
      if (activeArrayListHasNumber==2) {
        // activeArrayListHasNumber is FALSE, right side is active
        stroke(col3); // 
        line (1120, 405, 
          1210, 405);
         line (870, 320, 1330, 320);
        line (870, 340, 1330, 340);
         ellipse (865, 330, 6, 6);
      }
    
      PVector prev = new PVector(-1, -1); 
      int y=50; 
      for (PVector pv : points3) {
    
        fill(col3); // Blue 
    
        if (showText) {
          // show data
          text(pv.x, 1190-50, y+410); 
          text(pv.y, 1190, y+410);// 
        }
    
        fill(0, 2, 2); 
        stroke(col3); // blue 
        //float yvalue = map( pv.y, 0, height, 300, 355); 
        //if (prev.x!=-1) {
        //  line(10 + pv.x*3, yvalue, 
        //    prev.x, prev.y);
             float yvalue = map( pv.y, 0,1, 700, 180); // dimensione grafico GREEN
        if (prev.x!=-1) {
          line(80 + pv.x*55, yvalue, // linea grafico verde
            prev.x, prev.y);
        }
        noStroke(); 
    
      ellipse (80 + pv.x*55, yvalue, 4, 4);
        prev = new PVector(80 + pv.x*55, yvalue);
        y+=20; //next line
      }//for
    
      if (showText) {
     //   // middle line 
       stroke(col3); // blue 
        line( 1275-110,440,1275-110,720);
    
      }
      //
    }
    
    void showData4() {
      //
      // show data 4 
    
      color col4 = color(#FF00E6); 
    
      if (activeArrayListHasNumber==3) {
        // activeArrayListHasNumber is FALSE, right side is active
        stroke(col4); // 
        line (1230,405,1320,405);
        line (870, 350, 1330, 350);
        line (870, 370, 1330, 370);
         ellipse (865, 360, 6, 6);
      }
    
      PVector prev = new PVector(-1, -1); 
      int y=50; 
      for (PVector pv : points4) {
    
        fill(col4); //  
    
        if (showText) {
          // show data
          text(pv.x, 1300-50, y+410); 
          text(pv.y, 1300, y+410);
        }
    
        fill(0, 2, 2); 
        stroke(col4); //  
        //float yvalue = map( pv.y, 0, height, 300, 355); 
        //if (prev.x!=-1) {
        //  line(10 + pv.x*3, yvalue, 
        //    prev.x, prev.y);
         float yvalue = map( pv.y, 0,1, 700, 180); // dimensione grafico viola
        if (prev.x!=-1) {
          line(80 + pv.x*55, yvalue, // linea grafico viola
            prev.x, prev.y);
        }
        noStroke(); 
        ////   ellipse (10 + pv.x*3, yvalue, 4, 4);
        //prev = new PVector(10 + pv.x*3, yvalue);
         ellipse (80 + pv.x*55, yvalue, 4, 4);
        prev = new PVector(80 + pv.x*55, yvalue);
    
        y+=20; //next line
      }//for
    
      if (showText) {
        // middle line 
        stroke(col4); //  
        line( 1275, 440, 1275, 720);
      }
       { stroke(0); // BLACK 
    
        line( 1220, 400, 1220, 720); 
        line( 1220-110, 400, 1220-110, 720); 
        line( 1220-220, 400, 1220-220, 720); 
    
       }
    }
    
    // ---------------------------------------------------------------
     void serialEvent(Serial p) { 
      while (myPort.available() > 0) {
      inString = p.readString(); 
      char primo=inString.charAt(0);  // primo carattere
      String cifra=inString.substring(1);  // da secondo carattere in poi
      float val=parseFloat(cifra);          // valore da 0-255 o 0-1023, non sò cosa spedisce arduino
      print("primo=");  println(primo); //debug
    
      print("cifra=");  println(cifra); //debug
      print("val=");    println(val);
     // print(nf(val,0,2));
      switch(primo) { 
        case ('A'): MasA=(val);
         break;
    
        case ('B'): PCil=(val);
         break;  
    
        case ('C'): PAtm=(val);
          break;
    
       // case ('D'): Temp=(val);
         // break;
      } 
    }
    }
    
    void goBackToMainState() {
    
      // from help screen back to main screen
    
      // buttons ON 
     //MasA.setVisible(true); 
     // PCil.setVisible(true); 
     // PAtm.setVisible(true); 
     // myKnob4.setVisible(true); 
    
      //go back to main screen 
      state=normal;
    
      // kill Esc so we stay in the program 
      key=0;
    }
    
    void  backspaceOnActiveList() {
    
      // for the key BACKSPACE 
    
      switch (activeArrayListHasNumber) {
    
      case 0:
        if (points1.size()>0)
          points1.remove(points1.size()-1);
        break; 
    
      case 1:
        if (points2.size()>0)
          points2.remove(points2.size()-1);
        break;
    
      case 2:
        if (points3.size()>0)
          points3.remove(points3.size()-1);
        break;
    
      case 3:
        if (points4.size()>0)
          points4.remove(points4.size()-1);
        break;
      }//switch
      //
    }//func 
    
    // ------------------------------------------------
    // tools
    
    String nameFromPath(String fileName1) {
    
      File file = new File(fileName1);
      String result = file.getName();
      return result;
    } //func 
    //
    
  • How ro record audio?

    You should do everything in minim, instead of accessing audio using processing.sound. I will start with these :

    http://code.compartmental.net/minim/audioplayer_method_play.html
    http://code.compartmental.net/minim/minim_method_createrecorder.html

    You can also skip the arduino part. Instead, you can map senVal to the mouse position in the screen to simulate the arduino part:

    quick.rate(map(mouseX, width,0, 1, 0.25));

    Kf

  • How ro record audio?

    I am trying to use the minim library to record a mp3 that is manipulated with a motion sensor. However, the recordings I am making are coming up empty. Here is my code:

    import processing.serial.*;
    import cc.arduino.*;
    import org.firmata.*;
    import processing.sound.*;
    import ddf.minim.*;
    import ddf.minim.ugens.*;
    
    Arduino ardy;
    
    SoundFile quick;
    int senVal;
    Minim         minim;
    AudioOutput   out;
    AudioRecorder recorder;
    
    void setup() {
      fullScreen(P3D);
      noCursor();
      background(0);
    
      //Getting Arduino Data
      println(Arduino.list());
      ardy = new Arduino(this, "COM3", 57600); 
      ardy.pinMode(0, Arduino.INPUT);
    
      //sound
      quick = new SoundFile(this, "QUICKENING.mp3");
      quick.loop();
    
      //record sound
      minim = new Minim(this);
      out = minim.getLineOut();
      recorder = minim.createRecorder(out, "quickening_live.wav");
    
      frameRate(25);
    }
    
    void draw() {
      //Sensor Data
      senVal = ardy.analogRead(0);
      println(senVal);
      quick.rate(map(senVal, 70, 10, 1, 0.25)); 
    }
    
    void keyReleased(){
      if ( key == 'r' ) {
        if ( recorder.isRecording() ) {
          recorder.endRecord();
        } else {
          recorder.beginRecord();
        }
      }
    
      if ( key == 's' ){
        recorder.save();
        println("Done saving.");
      }
    }
    
  • bluetooth on android mode

    @robotman2412, @kfrajer=== i have tested the code i have put: it works for bluetooth; i cannot say for the arduino part.

  • Using Serial Library

    We are currently using the arduino ide to interact with our fpga. Now I want my Gui to interact with my fpga using serial communication.