Hello, as is obvious in the topic, I've been having trouble with Serial.println and accessing information in my 2D arrays. Whenever I try to read information in these, the board seemingly resets itself rapidly (it displays the messages in the setup loop over and over and over). Additionally, when it does work, I've occasionally had problems with the last variable in my array being replaced by a non-related character (-55 was replaced by ASCII character 253).
Is there a behavior of Serial.println that I've missed in the documentation?
Here's an excerpt of the code I'm using, distilled to the basics:
for(int i; i > 6; i++){ //no initialiser for the value of i. i can go beyond the number of array elements
for(int j; j > 3; j++){ //no initialiser for the value of j. j can go beyond the number of array elements
Starting with i at some unknown value, while i is greater than 6, do something and then increment i. If i starts at 1435, you are reading beyond the end of the array. If i starts at -182, you won't iterate at all.
If you do initialize i to 0, you won't iterate at all.
When I include the Serial.println in the excerpt I included in my previous post, the board seems to rapidly automatically reset. Further, nothing shows up in the serial monitor.
Mark_MedPhys:
When I include the Serial.println in the excerpt I included in my previous post, the board seems to rapidly automatically reset. Further, nothing shows up in the serial monitor.
How do you expect us to reproduce your issue?
But, it it's excerpts you like, here is an excerpt from the answer.
It is clear that the problem is .... Fix that, and all will work.
I had not expected anyone to reproduce the issue. Rather, I was hoping that someone had encountered a similar issue in a similar situation. If you know about any bugs with the command in question, or any useful tips that you can share with a newbie-level poster, I would appreciate it. Otherwise, go on with your day.
If anyone believes that they're wasting their time reading this, they really must be wasting their time in replying.
But it did change the problem.
Having variables of the same name with global and local scope can be confusing.
Having large amounts of data on the stack can be problematical.