Here's the problem: Lys runs on a single li-ion cell, providing a nominal voltage of 3.7V, down to 3.3V where the regulator for the microcontroller and peripherals stops regulating. I need to run six 350mA LEDs with a forward voltage of ~3.1V, but no cheap buck-boost nor boost converters were appropriate, and a buck topology would require one driver for each LED. Linear LED drivers in that current and voltage range are also way too expensive.
I could drive the LEDs with a simple resistor in series to limit the current, but then the light output would vary with the battery voltage, as the resistor value is constant... Unless there was a way to vary the resistance in the path of the LED. And yes, there is!
By applying a signal to the gate of a MOSFET, it adjusts the voltage across its drain and source. In effect we can see it as a voltage controlled resistor. Then we need a analogue signal to control the transistor, which cannot be supplied directly from the AVR, but can be created by passing a PWM signal through a RC filter. The Atmega168 has six PWM channels, just the right amount.
Now that we can control the current, we need to get some sort of feedback into our system by placing a current sense resistor in the path, and measure the voltage across it with the ADC. A PID controller can take care of the rest in software.
There you go, the 10 cent low dropout 350mA+ LED driver. Make sure the transistor of your choice can handle the power.