0
votes

I'm trying to get my arduino to communicate with a processing program. Every time I do it I get this error: "Error opening serial port /dev/tty.usbmodem1441: Port busy". My arduino is using the same port.

Here is my processing code:

import processing.serial.*;

  Serial myPort;    
  String val;

void setup()
{

  String portName = Serial.list()[5];    
  myPort = new Serial(this, portName, 9600);
}

void draw()
{
    if ( myPort.available() > 0) {    
        val = myPort.readStringUntil('\n');
    }
    println(val);
}

I got it from https://learn.sparkfun.com/tutorials/connecting-arduino-to-processing and I didn't change anything.

3
Just fyi: you can't have the Ardunio serial port monitor while trying t connect to the Arduino from Processing. (you don't mention if that is the case, but it is a common error).spring
Thanks a lot I did that and it worked!user61941

3 Answers

3
votes

If you have the Arduino serial monitor open, attempting to connect to the serial line with Processing will create a conflict, resulting in that error. Simply close the serial monitor and try starting the sketch again. (Maybe reset Arduino too by clicking Reset button near AREF)

0
votes

You cant use same port for two diffrent purpose at a same time.

check if that is the case. If thats not the case then try restarting arduino and pc both.

also make sure you are connected to the right port.

ls -l /dev/tty.*  should return all connected dvices if you are in unix system

if you are in window, may be its under device mager(its been long time i used window)

0
votes

Just close the "Serial Monitor" in Arduino and everything will work fine