I will try to make a more detailed sketch of the problem with measured values so that everyone can reproduce it
How in the world are you determining this?
How much is "slightly less"?
As said before the Arduino is NOT a power supply. If you are seeing 4V, it is still a logical "1" level, so digital logic still works. This is all that the digital pins are supposed to provide- a logical "1" or "0".
If you absolutely have to see 5V at the LED, then power it with a separate supply and control it with a GPIO pin driving a logic-level MOSFET.
Its not going to happen. If you think you need such precision control of your LEDs then you will need some external circuitry to make it happen.
A PC supply for the USB is limited to about 500ma and will shut down if much beyond that in order to SAVE THE PC from damage.
Yes, we are starting to see that...
I don't see why LED brightness should be of any concern.
Why don't you show us (code and diagram, according to the forum guidelines).
The Nano still works fine if the supply would drop to 4volt.
But for a 'voltmeter', you can't use that unstable default 5volt reference.
You must switch to the stable (not accurate) 1.1volt internal reference.
Well, that may well vary substantially - it may well happily provide much more than 500 mA as they are used to power external hard drives and such.
However that may be, in summary the OP here fails to comprehend a number of factors. The USB supply is limited by protective circuitry in the PC, so it is not necessarily a "stable supply" of precisely 5 V though it should be fairly well regulated.
Using a Nano, the connection to the "5V" terminal from the USB supply is through a diode, so there is a significant voltage drop dependent on the characteristics of that diode, so less "stable" overall.
An Arduino output pin has an effective internal resistance of about 27 Ohms at 5 V. What voltage it provides is completely dependent on how much current the load draws. There are curves in the datasheet to demonstrate this (since it is not entirely linear anyway).
So in summary, the voltage on the LED will never be entirely stable - and never needs to be since your eye cannot pick differences less than several percent. Even then it will only detect a sudden change in brightness, not a comparison. And a common ground wire is of no relevance whatsoever unless it is not properly connected.
Whatever do you mean by that?
The white LEDs I have contain two UV emitting devices and a phosphor to convert UV to visible light.
Thank you Paul_B for your answer, I will need some time to assimilate it!
Ok now it's getting clearer in my mind. I tried to make a refined sketch with relevant information only (no more "home-made" misleading digital voltmeter or LED connected to 5V pin!). On this sketch you can see a recap of the problem and can reproduce it yourself to observe the voltage drop. The Arduino code is just an analogWrite(ledPin, 0) for LEDs OFF and analogWrite(ledPin, 255) for LEDs ON with ledPin = 3.
I need for my project to keep the base voltage constant, irrespective of the LEDs. Here we can observe a decrease from 4.82V (when all LEDs OFF) to 4.78V (when all LEDs ON). Yes JohnRob, I really need such precision control.
Sorry if I misunderstood something, but why do we observe this drop? (which is more and more consequent when we add LEDs in parallel). Can we predict and quantify such a drop based on the electrical circuit?
It is a bit frustrating to add an external source of energy just for 0.04V... It sounds like an overkill! Would you guys confirm that the only way to keep 4.82 value constant is to add a power supply? and a GPIO pin driving a logic-level MOSFET (thank you SteveMann).
You are just not accepting the fact that the Arduino is a signal processor, not a power supply. Yes, you need an external power supply and FETs to turn the LEDs on/off from that power supply. The Arduino controls the FETs.
OK so if you need this type of regulation you must use external MosFet's. I don't believe the GPIO output has such a low source impedance that the output D3 will remain constant when driving different number of LEDs, even if the 5V is constant. You can probably see this in the Atmel specifications.
To control the output voltage to the LEDs I would recommend you look into a TL431 shunt regulator. It is a precision device. However it is a SHUNT regulator so you need to be sure your not trying to pull too much current from the +5V supply.
R1 should be high enough the TL431 does not draw too much current from the supply. R2 & R3 should be chosen to result in the V controlled is low enough that when all the LEDs are on the TL431 draws very little current. Then when only 1 LED is on the TL431 draws enough current to keep Vcontrolled at a constant voltage.
Vcontrolled must be slightly lower than the 5V line when all the LEDs are on.
I have not gone through the numbers so there may be a condition where this circuit is impractical, however I believe it is the simplest approach to your goal.
And you really need to sensibly explain why you are so concerned about the voltage to the LEDs being "stable"! Just "because" does not cut it!
Because there is - and will always be to some extent - resistance in the circuit. There is an effective series resistance internal to the PC providing USB power. There is an effective series resistance in the diode that is between the USB input on the Nano and the "5V" pin because diodes do not have a fixed voltage drop independent of the current passing through. While Zener diodes are for instance used as voltage regulators, their voltage does vary quite substantially depending on the current passing through them.
Voltage regulation is always a relative matter; the level of the sophistication of the regulator will depend on just how stable you really need the voltage to be and mostly it does not need to be that precise. Just why are you so concerned because those of us looking on find that a most improbable requirement for a LED?
So if they are in series, the LED requires more than 5 V. If they are in parallel, then it is just some oddity in the particular LED design. It is certainly most unusual for a white LED (except of course, for the higher power ones which are almost always a linear or two-dimensional array of chips).
And also unless they are hybrid cold/ warm white LEDs.
The voltage drop is caused by the power supply internal resistance. "Constant voltage supply" is a simplification, it does not exist in reality. Just learn to live with this and try to avoid circuits that need so precise supply. Why do you think you need it? Of course it is possible to get a better PS than a computer USB but you must know requirements for it.
I don't agree. Although I think the goal is foolish, perhaps there is a valid technical reason, perhaps the OP is OCD. In either case the OP asked for help so for me if I feel I have an answer and feel like showing my suggestion on how to accomplish his/her I will.
I wasn't trying to step on you post. If it came across like that then I'm sorry.
I deal with a OCD person weekly and they are the first to admit it! The problem seems to be the OP is not willing to accept reality.
I agree or else he is working on a top secret device using an Arduino
Pssst, that is a Ghostbusters device
No, that poster left because we were being mean to him by asking questions.
About the voltage drop phenomenon itself, I still don't understand why it can be explained by the power supply internal resistance .
I've finally reached my foolish goal using a PWM signal. While the LEDs are blinking or changing color, I've just determined the lowest voltage Vmin. I use this voltage as base voltage for my other top secret device set to analogWrite(ghostbusterPin, 255). Then, I try to make a model which determines the PWM value depending on the load and the voltage drop. When LEDs draw the maximum current, I use analogWrite(ghostbusterPin, 255) and then when LEDs change from White to Red and draw less current, I lower the PWM value, for instance analogWrite(ghostbusterPin, 253) to perfectly compensate the drop. This way, I don't experience voltage drop anymore.
It's a kind of programing solution instead of physical solution. If my model gets too complicated, I will go for MosFETs and TL431 SHUNT regulator, as JohnRob kindly suggests.
No need for external power supply, my insistance may have been regarded as OCD symptoms, it was actually me, as a newbie in electronic, trying to expose my issue in several ways to be sure everyone got it. Maybe you didn't really understand my concern. This is the single reality of our interaction.
Anyway, I'm still grateful when people tried to help