Arduino serial monitor outputs garbage with SPI hw libraries

I have a sketch that interfaces my MEGA board with a 4" TFT touch (ILI9486).
That part has been working fine but I just noticed that the serial monitor doesn't work anymore. It's displaying ⸮⸮⸮⸮⸮όS⸮⸮⸮⸮⸮⸮⸮ތ junk.
I've narrowed it down to:
#include <LCDWIKI_SPI.h> //Hardware-specific library
It appears to be hosing communications with the serial monitor because if I comment it and all references to it, serial monitor works.
Just for the heck of it I installed a different SPI hw library: ILI9486_SPI.h.
I tried one of its examples and the serial monitor put out junk for that one too.
I'm new at this stuff but seems like the serial communications for SPI are interfering with serial comm for the serial monitor,
Maybe?

And you have always made sure the baud rate in the code matches the baud rate in the serial monitor window, or whatever is receiving the serial transmission?

a7

yes. 9600

Time for the schematic & code… when you’re ready.

Well I figured it out but I can't explain why it behaved the way it did.
I had a function with 2 missing curlys---that did NOT produce an error when compiling. It was a Case Switch inside of a FOR inside of an IF ELSE. Very weird.

If it compiled, there were no missing curlys.

BTW thet are called braces. Even at the cafe no one sez curlys.

Not missing, but mismatched. Syntactically correct, but not what you meant. And what happened when it runs is not what you expect.

Post the “weird” code that compiles but has missing braces!

In the IDE there is a tool called autoformat, many times it can arrange your code better so you can see mismatched braces.

a7

Sorry. Braces. Got it.
Yes. I know about ctrl t. Use it often.
"mismatched but syntactically correct."
That must not happen very often -- but good to know that it can happen.
Thanks.

Haha, I guess that depends. I do it alla time. :expressionless:

I get into more trouble when I forget the braces altogether. Code looks good, but the compiler is sorta blind, it’s the braces not the visual layout.

At least in C/C++.

a7

Good to know that I'm not alone. The compiler is also flawed.

No it is not.
The compiler tries to make sense of what you give it, it doesn’t know what you mean only what you say. So if what you say makes sense to it then it compiles. You can write total rubbish in a code and it will compile if you don’t break any of the syntax rules.

A programmer’s girlfriend said to him, “ pop down to the shop and get a pint of milk, and if they have eggs get six”,
He came back with six pints of milk and when she asked why he had six pints of milk, he said “because they had eggs “.

Now you know that is not true because when did a programmer ever have a girlfriend?

Good to know. I just figured there was only one syntax that worked.
Silly me.

1 Like