100
Labels are used to reference locations in your program. They can be any combination of letters,
numbers and underscore (_), but the first character must be a letter. When used to mark a
location, follow the label with a colon. When referring to an address label in an instruction line,
don't use the colon. Here's an example
repeat: digitalWrite(2,HIGH);
delay(1000);
digitalWrite(2,LOW);
delay(1000);
goto repeat;
Use labels sparingly as they can actually make a program difficult to follow and challenging to
debug. In fact, some C programmers will tell you to never use labels.
Variables are allocated by declaring them in the program. Every variable must be declared. If a
variable is declared outside the braces of a function, it can be seen everywhere in the program. If
it is declared inside the braces of a function, the variable can only be seen within that function.
Variables come in several flavors including byte (8-bit, unsigned, 0 to 255), word (16-bit,
unsigned, 0 to 65,536), int (16-bit, signed, -32,768 to 32,767), and long (32-bit,
signed, -2,147,483,648 to 2,147,483,647). Use byte variables unless you need negative numbers
or numbers larger than 255, then use int variables. Using larger sizes than needed fills up
precious memory space.
Variable declarations generally appear at the top of the program
byte i;
word k;
int length;
int width;
Variable names can be any combination of letters and numbers but must start with a letter.
Names reserved for programming instructions cannot be used for variable names and will give
you an error message
Symbols are used to redefine how something is named and can be handy for making the code
more readable. Symbols are defined with the "#define" command and lines defining symbols
should go at the beginning of your program. Here's an example without symbols for the case
where an LED is connected to pin 2.
void setup()
{
pinMode(2,OUTPUT);
}
void loop()
{
digitalWrite(2,HIGH);
0x64
B01100100
// turn LED on
17
Need help?
Do you have a question about the uno and is the answer not in the manual?
Questions and answers