So i have set up my seeeduino with a bees shield and a bluetooth bee, and have got it working to the point i can use terminal screen to send commands, and it works.
Though now i am trying to control it using a processing program below:
import processing.serial.*;
Serial myPort; // Create object from Serial class
int val; // Data received from the serial port
void setup()
{
size(200, 200);
println(Serial.list());
myPort = new Serial(this, Serial.list()[6], 38400); //Serial.list()[6] is "/dev/tty.SeeeduinoBluetooth-DevB"
}
void draw() {
background(255);
if (mouseOverRect() == true) { // If mouse is over square,
fill(204); // change color and
myPort.write('1'); // send an H to indicate mouse is over square
}
else { // If mouse is not over square,
fill(0); // change color and
myPort.write('2'); // send an L otherwise
}
rect(50, 50, 100, 100); // Draw a square
}
boolean mouseOverRect() { // Test if mouse is over square
return ((mouseX >= 50) && (mouseX <= 150) && (mouseY >= 50) && (mouseY <= 150));
}
With the error:
gnu.io.PortInUseException: Unknown Application
at gnu.io.CommPortIdentifier.open(CommPortIdentifier.java:354)
at processing.serial.Serial.<init>(Serial.java:139)
at processing.serial.Serial.<init>(Serial.java:105)
at processing_bluetooth.setup(processing_bluetooth.java:33)
at processing.core.PApplet.handleDraw(PApplet.java:1608)
at processing.core.PApplet.run(PApplet.java:1530)
at java.lang.Thread.run(Thread.java:680)
Exception in thread "Animation Thread" java.lang.RuntimeException: Error inside Serial.<init>()
at processing.serial.Serial.errorMessage(Serial.java:591)
at processing.serial.Serial.<init>(Serial.java:151)
at processing.serial.Serial.<init>(Serial.java:105)
at processing_bluetooth.setup(processing_bluetooth.java:33)
at processing.core.PApplet.handleDraw(PApplet.java:1608)
at processing.core.PApplet.run(PApplet.java:1530)
at java.lang.Thread.run(Thread.java:680)