Arduino to Processing via Bluetooth Issue
in
Integration and Hardware
•
6 months ago
I hope someone can help me with a bluetooth and serial problem. I've searched the forum and can't find a similar issue.
I can see the data coming from the Arduino via bluetooth (COM12) with the serial monitor in the Arduino IDE and with SSCOM32E but cannot read it with Processing.
I have tried changing the BAUD rate on both ends, in Arduino and in Processing from 9600 to 115200.
Processing will print all the serial ports and then hangs or gives me some variation of the error:
java.lang.RuntimeException: Error inside Serial.<init>()
Hope someone can help. Any suggestions would be very great.
Code is below.
- String resultString;
- import processing.serial.*;
- Serial myPort; // The serial port
- void setup() {
- size(100, 100);
- println(Serial.list());
- myPort = new Serial(this, Serial.list()[2], 57600);
- }
- void draw() {
- while (myPort.available() > 0){
- myPort.bufferUntil('\n');
- String inputString=myPort.readStringUntil('\n');
- inputString=trim(inputString);
- resultString = "";
- float sensors[]=float(split(inputString, ','));
- for (int sensorNum = 0; sensorNum<sensors.length; sensorNum++) {
- resultString += "Sensor " + (sensorNum+1) + "= ";
- resultString += sensors[sensorNum] + " \t ";
- }
- println(resultString);
- }
- }
1