How to transfer value from arduino to processing

edited September 2014 in Arduino

Hi... i'm beginner, i want to ask something about processing, i want to show frekuensi value from arduino to processing, this is my ardu codeaaaaaaaaaaaaaaaaaaaaaaa

Answers

  • In order for processing sketch to communicate with arduino you need to import serial library. Web search led me to this article. The process should be clear, if you'll read it.

  • edited September 2014

    thank you for your answer ater, it's very helpfull.... but I just want to show frequensi value from arduino into processing.... not to read serial data from arduino to processing.... example in serial monitor arduino show : freq = 50; and i want to show the 50 into serial monitor processing can you help me?

    or may be like this : Arduino code : void setup() { Serial.begin(9600); } void loop() { ** int freq = 50;** // print out the value you read: Serial.println(freq); }

    and i want to into processing text(freq, 10,10,10);

    but it's cannot show :(

  • MahaisiwaTA, Ater's tutorial is everything you need to complete your sketch. Once you have read the value from serial port in processing, you just use text(name of your value,10,10,10);. It is also possible that your COM port is not the 4th on the list like it is shown in the Ater's tutorial. In processing sketch instead of String portName = Serial.list()[4];type number of COM port arduino is on. At the end, modified line should look like String portName = COM (number of COM port);. I hope this solves your problem.

  • edited September 2014

    you can use OSC to transfer your data from arduino to processing or from processing to arduino just download the library for processing there http://www.sojamo.de/libraries/oscP5/ and for arduino the library is http://cnmat.berkeley.edu/oscuino

  • when the arduino is still connected to the PC you can just say

      Serial.println("8x8 LED Matrix Test");
    

    to print in the console of the arduino IDE (no the processing IDE) afaik

    ;-)

  • @elektrogrammer : thnks for ur reply can u explain with the simple code ..... how to transfer value from arduino into processing... not use serial.data sorry i'm begginer I hope @sachaamm : can you teach me how to use the library? I cnt find the tutorial how to do it..... and I dont understand why it had net address >_< ... I just want to show the value @chrisir : lol :D .....jajajajajaj I want to show in processing

  • Well, there are many ways to transfer value from arduino to processing. You can do that by internet(probably not for you :) ), and the one you have chosen,** the USB cable**. Process itself is simple. Arduino writes on Serial port, Processing reads from it. To do that, you need a serial library in processing. This is the way i was talking about in my previous comment. The other way, which i haven't explored yet, is the one with arduino library in processing. It brings you commands like analogRead() into processing, but i think you need a specific code to be running on arduino. However, all of your programme can then be transfered to processing and you don't have to mess with writing and reading the serial port. Good luck with your further education :).

  • you wrote

    you have chosen,** the USB cable**. Process itself is simple. Arduino writes on Serial port, Processing reads from it. To do that, you need a serial library in processing. This is the way i was talking about in my previous comment.

    can you post the codes for both pls...?

    ;-)

  • edited October 2014

    Chrisir, you asked me to post my code. Well, sorry for not posting it in the first place.

    Here is arduino code:

    int value=0;
    void setup() {
    Serial.begin(9600);    //starts Serial library at 9600 baud rate
    }
    
    void loop() {
    value++;              //increments value
    Serial.println(value);      //prints value
    delay(1000);            //waits 1s
    }
    

    And here is the one from processing:

    import processing.serial.*;
    Serial myPort;
    String PORT;
    
    void setup()
    {
    size(200, 200);
    myPort = new Serial(this, "COM22", 9600);                
    //COM that your arduino is on. Mine is on COM22
    myPort.bufferUntil('\n');  
    }
    
    void serialEvent (Serial port)                    //when data is received
    {
     PORT = (myPort.readStringUntil('\n'));          //read to the end of the line
     }
    
    void draw()
    {
    background(0,0,40);
    fill(255);
    textSize(60);
    textAlign(CENTER);
    text(PORT,width/2,height/2);        //shows the value at the center of the screen
    }
    

    There is an issue with the readStringUntil() function in 2.0+ processing. That is the reason i use processing 1.5.1 when i am working with Serial library .You can get this release here https://www.processing.org/download/?processing under stable releases.

    I hope my codes help you with your work.

  • Thank you so much for sharing...

    I always feel the arduino forum (the one inside the processing forum) is not very strong...

    so thank you for submitting something that actually works

    I have an arduino and doing a robot atm.

    Best, Chrisir ;-)

Sign In or Register to comment.