We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I've had a little trouble with the sketch I wrote up in order to autoselect the port that my Arduino was on.
Arduino code: http://pastebin.com/4G7cNH4a
Processing code: http://pastebin.com/t12hmgq3
I wrote this applet for Windows, as I have never used OSX productively, and it is purely for personal use.
My Arduino repeatedly sends a char over Serial port COM4 (on USB). I told processing to set a serial object to Serial.list()[1], which should mean that the loop I wrote for selecting the port skips over index[0] in Serial.list(). This is intentional; external devices never connect to COM1 over USB, as far as I know.
In the looping function I wrote, portSelect(), what it's doing is checking to see whether there's any data available to read. Then, if there is, it checks to see if it's confChar. If it's not, it changes the value of the Serial object commsPort by setting it equal to Serial.list()[avIndex] directly after adding 1 to avIndex in the For loop.
I don't know what's going on, but I do know that none of the other applets I've written so far are doing this white screen thing. I'm completely stumped here; everything looks correct.
Also, first time on the forums :) I hope you guys have some nice feedback. Layman's explanations please, I'm relatively new to coding in general.
Answers
hi there,
it might be that you have the white screen, because your code failed somehow before you could finish your first draw. to be honest your
portSelect()
looks somehow overly complicated. i tried to make sense of your creative for loops, but i couldn't figure it out completly.here is a version how i would do it. i tried to comment everything thats important. just ask if you have any questions. since i don't have serialports active on my mac i couldn't test it fully. but i think it should work.
Thanks! No, no questions - the program does at least run now. However, you tweaked the avIndex to zero by default, meaning that the program begins scans at Serial.list()[0], which is somewhat purposeless - I know the Arduino is not connected there because it is not mounted on the nine-pin serial port via the motherboard. This does make it a more universal program, however, so thanks for that, I suppose.
It is instead wired to a virtual Serial port being emulated by USB, so I won't be COM1. This trips up the program just a bit. Thanks for writing such heavy revisions, though - it's greatly appreciated! I did run it, and while it experiences similar errors to earlier revisions (before whiteScreens began occurring), it does at least draw properly. Thanks again!
Beware of the term "applet", in general, at least in the Java world, it means "a Java program running in a browser". For small Processing programs, we prefer the term "sketch".
Also there is a forum section for Arduino, I moved your post there.
Thank you!