Let s see how this works and dissect the program s source code piece by piece.
In the first two lines, we define two
word.
refers to the number of the digital IO pin we re using, and
LED_PIN
defines the length of the blink period in milliseconds.
Every Arduino program needs a function named
4. A function definition always adheres to the following scheme:
<return value type> <function name> '(' <list of parameters> ')'
In our case the function s name is
returns nothing.
setup
list empty. Before we continue with the dissection of our program, you should
learn more about the Arduino s data types.
Arduino Data Types
Every piece of data you store in an Arduino program needs a type. Depending
on your needs, you can choose from the following:
•
boolean
values take up one byte of memory and can be
•
char
variables take up one byte of memory and store numbers from -128
to 127. These numbers usually represent characters encoded in ASCII;
that is, in the following example,
char
c1 = 'A';
char
c2 = 65;
Note that you have to use single quotes for
•
byte
variables use one byte and store values from 0 to 255.
• An
int
variable needs two bytes of memory; you can use it to store numbers
from -32,768 to 32,767. Its unsigned equivalent
two bytes of memory but stores numbers from 0 to 65,535.
• For bigger numbers, use
values from -2,147,483,648 to 2,147,483,647. The unsigned variant
unsigned long
also needs four bytes but ranges from 0 to 4,294,967,295.
•
float
and
double
are the same at the moment on most Arduino boards, and
you can use these types for storing floating-point numbers. Both use four
bytes of memory and are able to store values from -3.4028235E+38 to
3.4028235E+38. On the Arduino Due,
and occupy eight bytes of memory.
unsigned int
setup
, and its return value type is
doesn t expect any arguments, so we left the parameter
c1
and
long
. It consumes four bytes of memory and stores
www.it-ebooks.info
Hello, World!
constants using the
setup
, and ours starts in line
true
or
false
c2
have the same value:
char
literals.
also consumes
unsigned int
double
values are more accurate
17
const
key-
PAUSE
void
: it
.
report erratum
discuss
Need help?
Do you have a question about the Arduino Uno and is the answer not in the manual?