We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, I've been trying to use the serial port to connect to an external Bluetooth device. The program however will not allow me to use the Bluetooth port on my laptop, my Bluetooth port are 5 and 6 but the error: ArrayIndexOutOfBoundsException:5. I have used someone else's code so credit goes to them, The code is as follows:
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); }
Answers
Please format your code.
Press the gear icon to edit your post.
Select your code and press ctrl + o to indent.
Leave a line above and below.