in this code i'm missing the curly brackets! I understand what the code is doing but i dont understand why its working without the syntax of a normal if-process?!
The special question is: where can i implement the counting process when i only want to blink 3 times?
gnom:
in this code i'm missing the curly brackets! I understand what the code is doing but i dont understand why its working without the syntax of a normal if-process?!
The special question is: where can i implement the counting process when i only want to blink 3 times?
Thanks a lot for your patience
Z
The if/else syntax allows a single statement OR a block of statements. In C/C++ a code block is defined using curly brackets. In general, it is considered good form to always use curly brackets, but not necessary. If you want to execute more than one statement in your if or else block you MUST use curly brackets.
I'm not sure about your second question. If you want to blink 3 times you should use the millis() function to time the blinks. Here are some tutorials to look at:
Okay i understand but in my second example i'm missing the curly brackets and that was my question! You didnt answer my question. We i dont have any curly brackets here?
@ToddL1962: Sorry i didnt understand your explanation. UKHliBob's is what i understand! It's all equal and when i have only one statement everything is fine without curly brackets.
Thanks a lot! Thats helping! Perfect now the evening is saved and i can sleep well.
The best advice I can give is to always use curly brackets to enclose a code block and for them to be placed alone on a line. If you enter the opening one on a line of its own then the IDE will helpfully add a blank line and the closing one
I have Auto Formatting in the IDE set up to move curly brackets to their own line and, of course to indent the code block that they contain. It is the first thing that I do when I have copied code to the IDE. I do it as a matter of course as I do frequently when entering code of my own