Component:
Image Reference:
e7
e11
5V
330
Ω
Resistor
g4
e4
e7
e11
5V
330
Ω
Resistor
g6
e6
e7
e11
5V
330
Ω
Resistor
g7
e7
RGB LED
(5mm)
Jumper Wire
GND
Jumper Wire
5V5V
+
Jumper Wire
Pin 9
h4
Jumper Wire
Pin 10
h6
Jumper Wire
Pin 11
h7
e5
Jumper Wire
We've seen that the Arduino can read analog voltages (voltages between 0 and 5 volts) using the
analogRead()
function. Is there a way for the RedBoard to
output analog voltages as well?
The answer is no... and yes. The RedBoard does not have a true analog voltage output. But, because the RedBoard is so fast, it can fake it using something called
PWM ("Pulse-Width Modulation")
. The pins on the RedBoard with
“~” next to them are PWM/Analog out compatible.
The RedBoard is so fast that it can blink a pin on and off almost 1000 times per second. PWM goes one step further by varying the amount of time that the blinking pin spends HIGH vs. the time it spends LOW. If it spends most of its time HIGH, a LED connected to that pin will appear bright. If it spends most of its time LOW, the LED will look dim. Because the pin is blinking much faster than your eye can detect, the RedBoard creates the illusion of a "true" analog output.
The shocking truth behind analogWrite():
90%
90%
50%
50%
0.5V
2.5V
4.5V
LOW
(0 volts)
HIGH (5 volts)
LOW
(0 volts)
HIGH (5 volts)
LOW
(0 volts)
HIGH (5 volts)
10%
10%
a4
a5
a6
a7
Page 31
Содержание RedBoard
Страница 13: ...Page 11...