pert:
Do a Tools > Auto Format on your code and then check the automatic indentation to make sure it matches your intended program structure.
It is pointless to suggest using Tools + Auto Format, when there is clearly mis-matched curly braces. Tools + Autp Format won't work when the number of { and the number of } are not equal.
I see you say that often but I've never had that problem. Auto Format works fine for me on Windows with every IDE version I can remember using no matter how mismatched the braces are. Maybe it's an OS-specific thing? I can't imagine why that would matter
Here's mannan12's code after I did an Auto Format on it:
PaulS:
It is pointless to suggest using Tools + Auto Format, when there is clearly mis-matched curly braces. Tools + Autp Format won't work when the number of { and the number of } are not equal.
Auto Format works just as well when the number of { and the number of } are not equal. Whilst it will not (cannot) correct the error, it makes the fact that there are missing or extra brackets/braces more obvious.
I see you say that often but I've never had that problem.
The IDE has been improved, then. It used to just post a red bar with "Auto Format Cancelled. Too many xxxx curly braces", where xxxx was left or right. I'll stop mentioning the issue, then.
Actually that would a helpful message for beginners, though I wouldn't trade it for auto formatting. Maybe it was a limitation of older versions of the AStyle program the Arduino IDE uses for Auto Format.