if (j > 4) goto label
instructions
The commands inside the loop will be repeated six times. Following this, if the value of the
variable j is greater than 4, the program will skip to the instruction tagged with the specified
label, and if not, the line following the if statement will be executed.
In addition to the basic commands, languages have the ability to call functions which are
independent sections of code that perform a specific task. Functions are a way of calling a
section of code from a number of different places in the program and then returning from that
section to the line that follows the calling line. Here's an example
apples();
instructions
apples();
more instructions
void apples() {
instructions
}
The function apples is everything between the set of braces that follows "apples()". When the
function completes, the program jumps back to the line following the line that called the
function.
6.2 Digital Numbers
When working with a microcontroller that interacts with the real world, you have to dig a little
below the surface to understand numbering systems and data sizes.
A binary (base 2) variable has two states, off and on, or 0 and 1, or low and high. At their core,
all computers work in binary since their internal transistors can only be off or on and nothing
between. Numbers are built up from many digits of binary numbers, in much the same way that
in the base 10 system we create numbers greater than 9 by using multiple digits.
A bit is one binary digit that can take on values of either 0 or 1. A byte is a number comprised of
8 bits, or 8 binary digits. By convention, the bits that make up a byte are labeled right to left with
bit 0 being the rightmost or least significant bit as shown below
b7
b6
b5
Thus, in the binary number 011, bits 0 and 1 are 1 while bit 2 is 0. In the binary number
1000001, bits 0 and 7 are 1 and the rest are zero.
Here are a few binary to decimal conversions for byte size numbers.
Binary
Decimal
00000011
3
00000111
7
b4
b3
b2
b1
15
b0
Need help?
Do you have a question about the uno and is the answer not in the manual?
Questions and answers