This is my first time doing this, so forgive me for what seems like a very basic thing, I have read through both these articles, and I'm still not clear on the exact math to do.
http://learn.adafruit.com/all-about-leds/forward-voltage-and-kvl
https://learn.sparkfun.com/tutorials/voltage-current-resistance-and-ohms-law/an-ohms-law-experiment
First off, using this image:
http://www.hobbytronics.co.uk/image/data/tutorial/raspberry-pi/gpio-pinout.jpg
I think I have worked out that I should be doing this:
RPi pin 7 (GPIO 4) -> RGB LED Common Anode
RPi pin 11 (GPIO 17) -> RGB LED Red -> Resistor -> Ground wire
RPi pin 13 (GPIO 21) -> RGB LED Green -> Resistor -> Ground wire
RPi pin 15 (GPIO 22) -> RGB LED Blue -> Resistor -> Ground wire
RPi pin 6 (Ground) <- Ground wire
Given this RGB LED (Common Anode):
https://www.jameco.com/Jameco/Products/ProdDS/2128500.pdf
It seems the Vf is:
Red: 2V 20mA
Green: 3.5V 20mA
Blue: 3.5V 20mA
And I'm trying to calculate what resistor I should be using.. My first question is... are the pins on the GPIO 3.3V or 5V?
The main point I'm trying to wrap my brain around is if I'm supposed to subtract the Vf of the LED from the volts provided. Example:
Assuming the pin output is 3.3V, the Red is Vf of 2V with a current of 20mA, how would I calculate the correct resistance?
3.3V / 0.02A = 165ohms ??
or
(3.3V - 2.0V) / 0.02A = 65ohms ??
Or, given a 5V GPIO
5.0V / 0.02A = 250ohms ??
or
(5.0V - 2.0V) / 0.02A = 150ohms ??
Furthermore, with the Green and Blue.. if they have a 3.5 Vf, and the pin output is only 3.3V, do I need a resistor at all?