Hardware Reference
In-Depth Information
Note that in digital mode, there is a reasonable amount of tolerance; an input
of up to 2 volts is still considered to be a logical zero.
On the analog pins, things are different. An analog signal has an ini nite
number of steps between zero volts and the power supply of the Arduino. In
practice, it is not possible to sample an ini nite amount of values, and the Arduino
uses something called an Analog Digital Converter (ADC) to change the analog
signal to a discrete number of steps. The Arduino's ADC has a resolution of 10-bits,
which means there are 1,024 values that can be recognized on an analog input.
Connecting a Light-Emitting Diode
In this chapter, you have learned about basic electronic components, so now put
that to the test. In this example, you control an LED placed on a breadboard,
connected to an Arduino. The Arduino will be programmed to fade the LED.
In this example, I will use an Arduino Uno and also a blue LED. Check the
information about the LED you're using to determine the voltage and current
requirements. The LED I'm using has a forward voltage of 3.4 V and pulls
30 mA of current.
Calculation
LEDs must be used with resistors, so the i rst thing that has to be done is to
calculate the resistor that will be used. The Arduino Uno outputs 5 V DV, and
the LED has a forward voltage of 3.4 volts; therefore, the resistor will have a
potential difference of 1.6 volts. It will also let 30 mA of current pass. Because
we know the amperage and voltage of the circuit, we can i gure out the neces-
sary resistance. My calculation is shown in Figure 3-7.
V
I
R =
1.6
0.020
R =
R = 80 Ω
Figure 3-7: Calculating the resistor
Even though the LED is rated at an absolute maximum of 30 mA, you should
try and aim for less than 30 mA of current. A safe bet would be to let 20 mA of
current through the LED; that still makes it nice and bright and will not dam-
age the component. For the time being, let's assume you want to let 30 mA of
 
Search WWH ::




Custom Search