We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi all,
I'm working on a project with arduino and lately i got interested in processing too looks as a nice interface programming software which I'd like to use, so let's get to the main question. I'm totally new to processing so take it easy with me :D I saw some tutorials how to connect arduino with processing thru com port but I need to set my exact arduino com port and sometimes the com port changed depending on what computer i sit.
****Question: ****
Answers
This is how you find the list of COM ports, using Serial.list().
Here if there is only one COM port I go ahead and open it as that will be the connected Arduino (hopefully).
To create the GUI with a drop down list to allow the COM port to be selected I use quark's G4P (Available here)
The COMList.setItems(...) instruction updates the list of available COMports in the drop list control.
In case the sketch is run before the Arduino is connected, you may need to add a 'Scan' button that calls the getSerialPorts() function again as the list won't update unless you do it, but check to make sure the port is not already open ...
The COM port drop list object will have code something like this attached:
Hope this helps.
Phil.
Well thanks, I'm kinda new in processing so I'm in the learning process so I'm sorry if i can't take things fast.
I tried this code but i got some errors: COMList not recognized PortOpen does not exist and Type String[] of the last argument to method println(Object...) doesn't exactly match the vararg parameter type.
Hi Domino60,
Sorry for confusing you by just quoting snippets from my own code.
PortOpen is a global Boolean variable. I declare it before the start of setup()
boolean PortOpen = false;
COMList is an object created by the GUI Builder that you should be using to create your GUI for use with the G4P library. Did you add GUI Builder using the Add Tool... option in the Tools menu of Processing? Once you create a GUI with a drop list, call it COMList and GUI Builder will create an object called COMList which has the method 'setItems' so you can update the drop list with the list of your active COM ports as in
COMList.setItems(Serial.list(), 0);
Above screen shot shows GUI Builder open and I've highlighted the drop list and on the right, you can see I named it COMList.
The function
public void COMList_click1(GDropList source, GEvent event)
is created for you by the GUI Builder and it's called when an item in the COMList drop list is clicked on. The prinln call in there is also created by GUI Builder to help you know when that function has been called by printing the info in the debug area at the bottom of the Processing IDE window.I'm still pretty new to Processing myself so hopefully this won't confuse you even more!
Phil.