Nesting if/while

Hi, can anyone help me understand if / while? And how to properly nest one if/ while within another if/while ?

maybe:

otherwise give a more concrete example of what you are doing.

The 'if' and 'while' statements contain exactly one statement. That statement can be an 'if', 'while' or any other valid statement.

A block statement is '{' and '}' surrounding a list of statements. The single statement contained in an 'if' or 'while' statement can be a block statement. In the list of statements inside a block statement can be any number of 'if', 'while', or other valid statements.

Ok great, so that means you definitely CAN nest 'if's or 'while's. I was supposing either it was common practice, or that there may be a more elegant way.

6v6gt:
otherwise give a more concrete example of what you are doing.

+1

Seriously, spend some time with the Arduino examples that come with the IDE.

You can learn a lot from going through these.

You asked how to nest statements but hoped to get an answer to a different question: “Is there a more elegant way to (unspecified) than to nest if/while statements?” If Your code doesn’t feel elegant there is probably a more elegant way to do the same thing. If you show the sketch you want help with we might be able to suggest alternatives.