How to transfer message from arduino to processing?

edited May 2014 in Arduino

Basically, I want to see a message on processing console message which is by using arduino program. My message appears on Serial monitor, but I can't see it in processing.

A pertinent information is on site: https://learn.sparkfun.com/tutorials/connecting-arduino-to-processing/all

    import processing.serial.*;


    Serial myPort; //Create object from Serial class 
    String val;    //Data received from the serial port

    String portName = Serial.list()[0]; //change the 0 to a 1 or 2 etc. to match your port

    void setup(){
      myPort = new Serial(this, "usbmodem3d11", 9600); 
    }

    void draw(){
      if (myPort.available()>0){
        val = myPort.readStringUntil('\n'); //Read it and store it in val 
        println(val);                       //Print it out in the console
      }
    }

Answers

  • I am using 9600 boud rate on Arduino and processing. My serial port is usbmodem3d11 as I am using mac.

  • edited May 2014

    have you changed this line to match the number at which your usb serial connection is?

    String portName = Serial.list()[0];
    

    on my computer it is String portName = Serial.list()[6]; because usb is the 7th in my list. You can check by going to the tools drop-down and counting the list!

    Image of serial dropdown!

    if you do this you'll need to change this line: myPort = new Serial(this, "usbmodem3d11", 9600); back to myPort = new Serial(this, portName, 9600);

  • edited May 2014

    Ok. Yes it's kinda working. My serial list is 0 and I switched back to , but as soon I press RUN button on processing, my serial monitor is showing something weird like message. Take a look on image

    ![image alt text](Image of print screen)/Users/nick/Desktop/Screen shot 2014-05-11 at 10.18.34 PM.png

  • How do I past screen shots?

  • edited May 2014

    are you seeing a bunch of weird numbers and letters? that probably means the Baud rate doesn't match up! on arduino make sure to initiate the serial port with 9600 too. Serial.begin(9600);

  • Yeah, everything is initiated. It says null and sometimes I can see . No, I don't see any numbers. Screen shot 2014-05-11 at 10.18.34 PM This is that it looks like...

Sign In or Register to comment.