Just starting

I know this is a beginner question because it's about a sketch from a book called Beginning Arduino. :)

I type in the sketch for the project 2 SOS and when I compile I get this message:

error: 'x3' was not declared in this scope

with this line:

for (int x=0; x3; x++)


I've typed the code exactly as written in the book but it does not work. There are so many typos in this book that I am wondering if perhaps the problem is with how the author wrote it rather than with how I'm writing it.

Any help would be appreciated.

That may be a typo. Try x < 3 instead of x3.

The ‘for’ loop looks a bit like a function that takes three arguments, although here, those arguments are separated by semi-colons rather than the usual commas. This is just a quirk of the C language. The compiler will soon tell you when you get it wrong. The first thing in the parenthesis after ‘for’ is a variable declaration. This specifies a variable to be used as a counter variable and gives it an initial value, in this case 0. The second part is a condition that must be true for us to stay in the loop. In this case, we will stay in the loop as long as ‘x’ is less than 3, but as soon as ‘x’ is 3 or more, we will stop doing the things inside the loop. The final part is what to do every time you have done all the things in the loop. In this case that is increment ‘x’ by 1.

edited slightly from my book: Programming Arduino: Getting Started with Sketches (http://www.arduinobook.com)