Please explain { to me.

Yeah, a noob question I know. But I'm having a "logic" problem that I believe revolves around an incomplete understanding of what { and } do in this context. Can you fill me in?

Can you be more specific m8?

My first assumption was that it was used to nest functions. So, {1+2}/3 has a different meaning from {1}+{2/3}

And it appears to be used that way sorta, but not in the way I would expect. When I try to use it the same way I would use it above, sometimes things compile okay, sometimes they don't.

Understand, I'm in second program so it's not like I know what the hell I'm doing. But it behaving unexpectedly i.e. not exactly like a () in math. So I was hoping for a general exposition on what it does in the Ard. environment.

I am still not sure of what you mean, but I think, if you havent already done so, you should take a look here:

The simplest explanation is that the {} brackets group multiple statements into a single statement (that a drastic simplification)

Take if for example

if (condition) statement else statement

that might be if (a == 10) b = 20; else b = 42;

or it might be

if (a == 10)
{
b = 20;
do_something();
}
else
{
b = 42;
do_something_else();
}

{} - Arduino Reference for a better description

You are confusing parenthesis () with curly braces {}

Parenthesis are used to enclose values or to define how you want a calculation to be evaluated

1+23 would give the value of 7, not 9 as you might think and that is because the * operator has precedence over the + operator and theerfore the 23 is calculated first.

To make it work to give you a value of 9, you would need to enclose specific sections of the calculation in parenthesis, e.g. (1+2)*3 - This would calculate the 1+2 first (as the parenthesis have precedence over the * and +) to get 3 then 3 gets multiplied by 3 to get 9.

Parenthesis are also used to enclose parameters on functions.

Curly braces are simply there to tell the compiler where a code block starts and ends. E.g.

for (int x; x <10; x++)
{
// do something here
}

Thanks guys. Now that I know they're called "braces" I can look it up as you all pointed out.