We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I've been thinking about this problem for a couple weeks, came up with several possible solutions, but none have worked, so I'm looking for suggestions, ideas, or a good general direction to start thinking along.
I wrote a rather large applet that does a couple different things; sometimes, but not always, it will be connecting to an arduino via an HC-06 bluetooth module (the code is exactly the same as using serial through USB) . Sometimes I will need to run the program without connecting to serial. If I use Serial.list() it doesn't choose the right port, if the port is not available, the program doesn't run at all.
I need a method that connects if the port is available, but just ignores it and runs the program if it is not. Is there a function I can use to check the port before initializing, that way if it's not there i can tell my program not to use any of the portions that require serial communication?
Thanks
-J
Answers
Serial.list()
will give you a list of the serial-ports that are available. You should be able to check if your arduino-port is available like this:you migt have to change the name and index, on my system the arduino shows up with this name as the third serial-port. I suppose it is different on your system.
Thanks!