https://www.instructables.com/id/DIY-Dodow-Clone-Arduino-Sleep-Meditation-Machine/
Below details how you'd select which resistors to use with the circuit... I think I'd drank to much coffee that day so be warned, it's pretty long-winded & boring.
The Finished Dodow Clone |
You have been warned!
Resistance is Futile: A brief Introduction to Ohm's Law
Suggested music to learn Ohm's Law: Steve Moore 'Pangaea Ultima' album
You'll need an LED, resistor, wire and a breadboard. How to tell which resistor to use? For this we can use Ohm's Law, which can be remembered as a Very Important Rule aka VIR.
V = Voltage
I = Current (don't worry that it doesn't begin with an 'I' as that was already taken)
R = Resistance
Ohm's law allows us to figure out one of the above, if we already know two of the others. E.g If you knew the current and the resistance of something, you could work out the voltage needed.
So what do we know, and what do we need to know. We're trying to work out which value of resistor we need, so we're trying to figure out the resistance (R). So let's see if we can work out the other two parts of Ohm's law, voltage (V) and Current (I).
So lets try voltage first, how much voltage does an Arduino Uno pin output? Well lets try putting that into google;
5 volts. So now our problem looks like this;
V = 5 Volts
I = ???
R = ???
So lets see the current needed that will pass through an LED. For this I'll google 'LED Datasheet' which should give us all the possible info on LEDs. The second result looks simple, so I'll click that;
From which it gives us the information;
This is a very basic 5mm LED with a red lens. It has a typical forward voltage of 2.0V and a rated forward current of 20mA.
Ok, so we can learn two things from this, that to power these LEDs takes about 2 volts (max of 2.2 before she'll blow up), and a current of around 20mA. But hang about our Arduino pin supplies a max of 5 volts and these LEDs require 2 volts to run, won't we risk blowing up the LED? Yes! That's why we're working out the value of the resistor to protect it...
Now our VIR looks like this;
V = 5v minus the 2v that we need to run the LED. This leaves us with 3 volts.
I = 20mA, which to be able to use in ohm's law we need to convert to amps.
R = ????
Now lets convert the 20mA into Amps, you could work this out by moving the decimal place, but come on, lets just use an online tool;
20mA = 0.02 Amps.
So now we have;
V = 3 volts
I = 0.02 Amps
R = ???
We're nearly there (All this for a resistor value ffs!), but now we just need to now the calculation to use to get the resistance, for this let's take a look at the Ohm's Law Triangle;
Not only does it look cool (think band logo or over priced bagel shop) it's actually showing us which rules to use depending on what information you have. If you knew Current (I) & Resistance (R) you would multiply to get Voltage (V), see here;
Whereas if you knew voltage (V) and one of the others you'd divide, like this;
So let's try that;
V = 3 volts
I = 0.02 Amps
R = ???
3 / 0.02 = 150
150 Ohms! Anything under that and there's a chance the LED will be fried, infact it's good practise to go by the 1/3 rule... give yourself an extra 1/3 than the minimum needed. so 1/3 of of 150 is 50, so to be safe from any power fluctuations etc we'll use a 200 Ohm resistor (150 + 50)... except I'll actually use 220 Ohm resistor as it's a lot more of a standard value.
So that's how we come up with the resistor value. It's a little long winded but you'll eventually get there pretty quickly with practise. Or just use a 1k Ohm resistor like lots of other people generally default to ;-)
Before we leave this section, we can double check our maths with the Ohm's Law pyramid, substituting differing known quantities;
V = 3 volts
I = 0.02 Amps
R = 150 Ohms
If you knew V and R but not I, according to the pyramid you'd do the following;
V / R = I
which is;
3 / 150 = 0.02 amps
And ff you knew R and I but not V, according to the pyramid you'd do the following;
R x I = V
which is;
150 x 0.02 = 3 Volts
So you can see how the Very Important Rule can be used in different ways if you only have certain information to hand. This may be of some use to you one day. Or maybe not.