This is a circuit that can be used both to control LEDs, and for charging a battery powering a circuit or as a tool for our laboratory, and is useful for those who work a lot with LEDs and otherIt comes either a constant current source as a test of LEDs. We can also be used to charge batteries, but we must change the value of resistance in both strength and power.

The calculation to obtain the desired output current will be mentioned in the diagram, where Vref to the LM317 will be 1.25V, in our case we use a LM317T which has a TO220 encapsulation and can drain up to 1.5A, mounted on a heatsink heat. In this circuit the sink is not necessary because we only need 10mA, so also could change the LM317T for LM317L is encapsulated TO92 and we can dispense up to 100mA. Being a current of up to 30mA for LED high standard brightness, perhaps you could replace the resistances of 240 ohms, by a potentiometer (with a series resistor to limit consumption) or by a selector switch and different groups resistances where you can setear eg 10, 20 and 30 mA. The supply voltage ranges from 3.6V to 9V without presenting alterations in the current dissipation so too does a portable device. Then I will show the simulated checking circuit current calculations, in our case we used two 240 ohm resistors in parallel for 120 Ohms. The resistors are 1 / 4W.

Here we can see the version with a 3-way selector where we can give different resistance values for different output currents. The values found are theoretical in the circuit, so resistors to be used with 1% tolerance to find the standard, or values, should previously make a series / parallel network to achieve the closest values. You can also use a preset for each value, but bear in mind the current to pass through the preset.