I am making a circuit simulation program, and I am not sure how to simulate the behavior of Diodes.
Take this circuit:
------100 Resistor -----LED------
Positive 5V-----470 Resistor-----| |---------Negative 5V
-----------200 Resistor----------
How would you calculate the voltage and current through all of these components?
Also, is it true that with a simple circuit like this:
Positive 5V------470 Resistor------LED--------Negative 5V
That you would subtract the forward voltage of the LED from the Battery's voltage, then use Ohm's law to calculate the current and resistance through the circuit?
voltage = 5;
newVoltage = voltage - forwardVoltage;
current = newVoltage / 470;
resistance = voltage / current;
Thanks for the help.