vikan:
2. stupid question but.. can I write like in C, C++ a loops and if cases without theese "{}" if I only have a single statement after? like..
for(something)
doThis();
Hi vikan,
The language that is used to write the sketches is C++ (see this post: Read this before posting a programming question ... - Programming Questions - Arduino Forum) so anything you can do in C++ (or C for that matter) you can do in a sketch.
These: "{}" are commonly called "braces" or "curly brackets", just so you know what they are called for next time.
as for usage, what Claa said above is correct, you can leave them out, however, in my opinion, this is bad practice, especially for beginners. You may save yourself a few seconds by omitting them, but what I often see happen is that at some point, you come back and try to add a second line, and you forget to add the braces in.
For example, say you have written this code:
if(someCondition)
doSomething();
then you need to make it do more, so you come back and add another line, but you forget the braces:
if(someCondition)
doSomething();
doSomethingElse();
then this code will cause a bug in your program, it essentially the equivalent of having:
if(someCondition)
{
doSomething();
}
doSomethingElse();
Which is not what you intended, but may not be immediately apparent.
If you get into the habit or taking the time to always add the braces, it helps to cut down on mistakes like this.
As for the piezo, I found that mounting it in the 5th hole of a row of 5 holes, it left just enough room to connect wires to the first holes in the group of 5. (I hope that makes sense)
I apologise for the wall of text, but I hope that helps