Hello, I have been having some trouble getting Processing code to send data though the USB2SERIAL to the Arduino. The SoftwareSerial library is what i'm using to take the incoming information and then mySerial.print(val) the value back to the computer. This is where I run into problems: the Arduino can print things to the computer through the USB2SERIAL converter, but when information is sent to the Arduino from a PC and the Arduino printing them back to the PC is when things stop working correctly. The serial monitor shows a mess of information.
Here is the output:
I Received: -1
I Received: -1
I Received: -1
I Rec255
I Recei
I ReceivedReceived: -1
Ieived: -1
I Reed: -1
I Recei -1
I ReceivedReceived: -1
Ieived: -1
I Reced: -1
I Recei -1
I Received2
I Received: I Received: -1
eceived: -1
I Rece: -1
I Receiv15
I Received:
I'm am rather confused on where the -1 and 255 is coming from, because the number sent to the Arduino from Processing is a 15, which only shows up once and a while. The couple of things I thought that it could be is: packet collisions and Processing is saying: RXTX Warning: Removing stale lock file. /var/lock/LK.059.033.126
Any help would be appreciated
This is being ran on:
OS X 10.8.2 (12C60)
2.2 GHz Intel Core i7
8 GB 1333 MHz DDR3
If this is the wrong place to post this please forgive me
~Thanks Idan
Here is the code that I am using
Processing code
import processing.serial.*;
int i;
Serial port;
void setup()
{
println(Serial.list());
port = new Serial(this, Serial.list()[4], 9600);
}
void draw()
{
port.write(15);
delay(100);
println("testing");
}
Arduino code
#include <SoftwareSerial.h>
int i;
SoftwareSerial mySerial(9,8); //set tx and rx pins
void setup(){
//set up serial comunication
mySerial.begin(9600); //speed of serial port used by NewSoftSerial
}
void loop()
{
// read the incoming byte:
i = mySerial.read();
//then print it
mySerial.print("I Received: ");
mySerial.println(i);
}