martes, 5 de abril de 2016

The basic programing of Arduino.

To start with our first program we need an Arduino Uno board or similar (though this session accepts any other model Arduino), a suitable USB cable to our PC with Arduino and Arduino environment correctly installed and configured. If we have this we can start now.
Arduino is programmed in a variant of C ++, which is a widely used language for its features, though not plain language. C ++, which sets strict rules on how to write these instructions. A program is a set of instructions that are executed in sequence (unless expressly we indicate precise conditions under which this sequence is altered). An internal program checks the syntax of our program is in line with standard C ++, and if there is anything that does not convince you will fail and end checking forcing us to review what we have written. When the tester accepts our program invokes another program that translates what we have written in comprehensible instructions for the processor of our Arduino. This new program is called a compiler. The compiler converts our instructions (source code) in processor instructions (executable code).
 A program or Arduino sketch consists of two sections or basic functions:

-Setup: Your instructions are executed only once, when the program starts when you turn Arduino or when you press the reset button. Generally it includes definitions and initializations hence its name.
-Loop: Their instructions are executed in sequence until the end .... And when it ends, start again from the beginning by an endless cycle.

When we open the Arduino IDE (or do [Menu] \ File \ New) he writes and these two functions (copper color):
Note that the beginning of each function is indicated by the key opening "{" and so it corresponds to the symbol keys closing "}".
In fact the set of instructions between an opening and closing braces is called block and is of paramount importance when our Arduino interpreted in one way or another we give instructions.
It is imperative that each opening of a key corresponds with a key lock. In subsequent chapters we expand this concept.

For now highlight the lines that appear within the main blocks:

// Put your setup code here, to run once
// Put your main code here, to run Repeatedly

Anything you write preceded by "//" are comments and are ignored. That is we can leave messages in the code (which would otherwise errors). The compiler will ignore anything between // and the end line.

No hay comentarios:

Publicar un comentario