Programming Arduino Getting Started with Sketches


LOW . Analog Outputs



Yüklə 5,42 Kb.
Pdf görüntüsü
səhifə51/78
tarix22.12.2023
ölçüsü5,42 Kb.
#189286
1   ...   47   48   49   50   51   52   53   54   ...   78
Arduino SimonMonk 2011

LOW
.


Analog Outputs
A few of the digital pins—namely digital pins 3, 5, 6, 9, 10, and 11—can provide variable
output other than just 5V or nothing. These are the pins on the board with a ~ or “PWM”
next to them. PWM stands for Pulse Width Modulation, which refers to the means of
controlling the amount of power at the output. It does so by rapidly turning the output on
and off.
The pulses are always delivered at the same rate (roughly 500 per second), but the
length of the pulses is varied. If you were to use PWM to control the brightness of an
LED, then if the pulse were long, your LED would be on all the time. If, however, the
pulses are short, then the LED is actually lit only for a small portion of the time. This
happens too fast for the observer even to tell that the LED is flickering, and it just appears
that the LED is lighter or dimmer.
Before you try using an LED, you can test this out with your multimeter. Set the
multimeter up to measure the voltage between GND and pin D3 (see 
Figure 6-11
).
Now upload sketch 6-08 to your board and open the Serial Monitor (see 
Figure 6-12
).
Enter the single digit 
3
and press Return. You should see your volt meter register about
3V. You can then try any other number between 0 and 5.


Figure 6-11
Measuring the analog output
Figure 6-12
Setting the voltage at an analog output
The program determines the value of PWM output between 0 and 255 by multiplying


the desired voltage (0 to 5) by 51. (Readers may wish to refer to Wikipedia for a fuller
description of PWM.)
You can set the value of the output by using the function 

Yüklə 5,42 Kb.

Dostları ilə paylaş:
1   ...   47   48   49   50   51   52   53   54   ...   78




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin