Pages: [1]   Go Down
Author Topic: variable from Processing to Arduino Serial port already in use?  (Read 961 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm trying to send a variable from Processing to Arduino I have been splicing code from a few examples to make a simple test but I get an error that says port is ready in use.

is the basics just
Code:
serialPort = new Serial(bla,"myArduinoSerialPort", bla);
?

sends something in processing to Arduino as ascii
Code:
serialPort.write(somethingASCII)
reads the variable on the Arduino.
Code:
val = Serial.read();
here is my processing code
Code:
import processing.serial.*;

Serial myPort; 
int val =0;       

void setup()
{
  size(175, 175);
  myPort = new Serial(this,"COM8", 9600);//COM8 is my Arduino
}

void draw() {
  myPort.write(val);
  val++;
  if(val > 50)
   val = 0;
}

and here is my arduino code
Code:
int val;
void setup()
{
  Serial.begin(9600);   
}

void loop()
{
 if (Serial.available()) { // If data is available to read,
     val = Serial.read(); // read it and store it in val
     }
     
     
Serial.println(val);
}

I get an port "COM8" already in use
"COM8" is what my arduino is useing

any ideas of what im doing worng?
thanks!!!
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 553
Posts: 46267
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I get an port "COM8" already in use
"COM8" is what my arduino is useing
Then close whatever application is using the port. Do you have the Serial Monitor open, too?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Any breakthrough yet? I am facing the same problem as well.
Logged

Melbourne
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi

I had the same problem.  I tried reloading over the original Arduino 1.0.1 folder as well as creating a new directory and having a second copy.  Neither of these worked and I kept getting the message that COM8 was already in use.

In the end I checked which Arduino board was selected.  Some how the IDE had lost its original setting of ATmega1280 and had defaulted to the first board on the Tools/Board menu.  Resetting the board to ATmega1280 fixed the problem.

Hope this helps someone

Jayne
Logged

Pages: [1]   Go Up
Jump to: