Hardware Reference
In-Depth Information
1
2
3
4
5
8
9
10
Figure 1-13: The components of the Blink program
5. The Arduino's digital pins can function as input or outputs. To configure
their direction, use the command pinMode() . This command takes two
arguments. An argument gives commands information on how they should
operate. Arguments are placed inside the parentheses following a com-
mand. The first argument to pinMode determines which pin is having its
direction set. Because you defined the led variable earlier in the program,
you are telling the command that you want to set the direction of pin 13.
The second argument sets the direction of the pin: INPUT or OUTPUT . Pins
are inputs by default, so you need to explicitly set them to outputs if you
want them to function as outputs. Because you want to light an LED, you
have set the led pin to an output (current is flowing out of the I/O pin).
Note that you have to do this only one time. It will then function as an
output for the rest of the program, or until you change it to an input.
Search WWH ::




Custom Search