Go Down

Topic: Processing to Arduino problem (Read 1 time) previous topic - next topic

MWhetherly

Thanks to all of you. I had read online in one explanation that eventually lead to trying 'Serial.list()[2]', I had done the same code with but with Serial.list()[0] and it didn't work. I just tried it again now and it worked perfectly fine.

I'll just put it down to tech being tech.

Thanks again.

PeterH


I'll just put it down to tech being tech.


No, put it down to you using arrays incorrectly and happening to get lucky sometimes.

Before using an element of the array you should ensure that the element is within the bounds of the array and that it contains the item you want. Here you have no reason to assume that there are at least three serial ports or that the third one corresponds to the Arduino. If you are actually trying to assume that the Arduino will be on the serial port named "COM3" then IMO you might just as well hard-code that value rather than assume that the right name is at index [2] in the list of port names.

(Better would be to provide some way for the user to see and select from the list of available ports.)
I only provide help via the forum - please do not contact me for private consultancy.

michinyon

Quote
I'll just put it down to tech being tech.


You need to develop an understanding of what you are doing.   

Different computers have different numbers of serial connections ( or , these days,  usually a USB connection pretending to be a serial connection ).   With both the Arduino and Processing,  the serial connections vary all the time on my computer and it is one of the most annoying aspects of using the Arduino for me.

In your case,   the error message you got was actually pretty clear to me,   and I am as far as it is possible to be from being a Processing expert, having only used it once,  and disliking it.

mistergreen

I like processing. It's pretty flexible. If you know JAVA, you can extend its power like if you know C++ for the Arduino IDE.

MWhetherly

Thanks guys, I do understand the theory and I had actually originally had it written as it is now (and working), but it wasn't working at the time. So I followed some other stuff online and the only thing I changed was the 2 in the array. When I changed it back it worked. That's what I meant by tech being tech, I didn't mean to sound like I had no appreciation for what was happening so long as it worked.

Go Up