Hardware Reference
In-Depth Information
Figure 3-13.
You can only use pins capable of Pulse Width Modulation with
analogWrite()
. These pins are indicated with a tilde (~) next to the pin num-
ber on the board.
The syntax of
analogWrite()
is:
analogWrite(pin, value);
The parameters of
analogWrite()
are:
•
pin
: the pin number
•
value
: an integer between 0 (totally off) and 255 (totally on)
analogWrite()
does not return a value.
Try the function out now to make an LED fade up and down, much like the
LED on some computers that shows it's “sleeping.”
1. Connect an LED to pin 9 of your Galileo the same way you did in
“Pin
Numbers” on page 28
. Don't forget to include a current limiting resistor
in your circuit as shown in
Figure 3-5
.
2. Within the Arduino IDE, click File
→
Examples
→
01.Basics
→
Fade to open
the
analogWrite()
example.
3. Click upload.