user61941
user61941

Reputation: 37

Processing serial port error

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.

Upvotes: 1

Views: 10190

Answers (3)

AsmaAP
AsmaAP

Reputation: 31

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

Upvotes: 1

Ccr
Ccr

Reputation: 686

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)

Upvotes: 0

Brendan
Brendan

Reputation: 43

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)

Upvotes: 3

Related Questions