Help Calculating the resistance required.

So, I've got my Arduino powered by a 7V battery. I have a jumper wire going from 'GND' to a digital pin through a resistance and speaker of 8Ω and 0.25W.

The equation I'm using for calculating resistance:

(Source Volts - LED Volts) / (Current / 1000) = Resistance

For the speaker of 0.25 W and 8 ohms I get 176.776695 mA and 1.41421356 V.

(Source Volts - Speaker Volts) / (current / 1000) = resistance
(7V - 1.414V) / (176.78 / 1000) = 31.6 Ω.

Did I do that right? Will I have to connect 31.6 Ω resister to the jumper wire, then solder it to the speaker wire's end (cathode); take the other end of the wire (anode) and insert it in whichever digital pin I want?

Sorry if this a noob question, I'm very new to this.

Do it the other way.
Max current an Arduino pin can supply is 40mA.
If you work that out for 5volt (5/0.04), you get 125ohm.
The internal pin resistance is ~40ohm, so external could be 85ohms.
Subtract 8ohms (speaker) = 77ohms.
This value could kill your Arduino......

Better to work with 20mA. >>> 202ohm.
The safe/practical value is 220ohms.
A value you see pop up many times.

LED calculations are a bit different.
You have to know the LEDs forward voltage, and drive current.
Leo..

Wawa:
Do it the other way. Max current an Arduino pin can supply...
...
...
You have to know the LEDs forward voltage, and drive current.
Leo..

Thanks a lot for your reply. Since I cannot change the voltage of the battery, I'll have to work with 5.586 V (7V - 1.414V). When I calculate the resistance for that, I get 231.3 ohms. So, should I get a resistor which has a higher value than 220 ohms?

You power Arduino with 7V battery but Arduino board has a voltage regulator which drops the voltage to 5V. So any digital and analog pin on arduino is 5V tolerant.

For LED use 220 Ohm resistor. Or higher - even 2k will be ok but LED will be dimmed.

waski:
You power Arduino with 7V battery but Arduino board has a voltage regulator which drops the voltage to 5V. So any digital and analog pin on arduino is 5V tolerant.

For LED use 220 Ohm resistor. Or higher - even 2k will be ok but LED will be dimmed.

And the same (220 ohm resistor, for we calculated for that earlier) should work with the speakers too, yes? If yes, how come that both the LED and the speaker can work with 220 ohm resistor? If in the LED case, 220 ohm resistor is ideal, won't the speaker require more?

They can work with 100Ohm, 220Ohm, 470Ohm, 1,2kOhm , 3kOhm... Calculate current for 220Ohm resistor at 5V . Then calculate power. Then look at your speaker.... ( we skip internal resistance of digital pin, voltage drops, speaker impedance etc just to simplifies things ) .

The important factor is CURRENT.
You should keep pin current at ~20mA or less.

e.g. you want to drive a 1watt white power LED directly with the Arduino.

Arduino can't supply the ~300mA required, but let's try to light it up to max with the Arduino.

LED forward voltage is ~3.3volt. Arduino out is 5volt.
So the current limiting resistor has to drop 1.7volt.

That gives 85ohm (1.7/0.02).
We already have 40ohm internal, so we could use a 45ohm resistor. 47ohm practical.

...not all LEDs have a 3.3v forward voltage!
Leo..

All right, I got it. Thanks everyone, really appreciate all the help. :slight_smile: