You can certainly drive low power LEDs with a single inverting transistor.
Keep in mind a few rules of thumb for low voltage LED drive since millivolt drops and impedance ratios matter in transistors.
- read and understand the LED datasheet throughly, especially the VI curves, same for transistor like P2N2222A
- Vce(sat) is always rated for 10% base current but at low current you can get away with 1% base current 0.1V rise in the P2N2222A. Meaning, as the transistor saturates, the hFE drops to 10 at two typical current levels.
- Include above in Ohms Law or KVL calculations.
treat the transistor like a switch with series R or Rce ( resistance for CE as a switch is given in some datasheets at Diodes Inc.) but I just call it Equivalent Series Resistance or ESR where ESR~0.5 * 1/Pd rating ( @85'C also 2:1 mfg tolerance) so if rated for 0.5W @85'C then 1 Ohms. ESR applies to all logic devices too , and FETs (RdsOn) and caps and coils (DCR) So a 1W LED has 10x the ESR as a 10W LED (or any diode or transitor)
5V Logic starts around 50 Ohms and drops around 25 Ohms for 3.3V logic chips (50% tolerance) for direct drive scenarios. ( old 15V logic was around 300 Ohms)
But before you reinvent the wheel, there are about 10 thousand different LED driver designs so read! often.
IS31FL3194 is a 3-channel LED driver which features
two-dimensional auto breathing mode. It has Pattern
Mode and Current Level Mode for RGB lighting effects.
The maximum output current can be adjusted in 4
levels (40mA Max.).
In Current Level Mode, the current level of each output
can be independently programmed and controlled in
256 steps to simplify color mixing. In Pattern Mode, the
timing characteristics for output current - current rising
(T1), holding (T2), falling (T3) and off time (TS, TP, T4),
can be adjusted individually so that each output can
independently maintain a pre-established pattern
achieving mixing color breathing or a single color
breathing without requiring any additional interface
activity, thus saving valuable system resources.
The following features are only partially or not supported by Espruino on the ESP8266:
No hardware I2C, however, the software I2C works OK.
PWM does not work, low speed software PWM is usable
No DAC: the esp8266 does not have a DAC.
No independently usable serial port (needs Espruino work)
GPIO16 is now supported in Espruino as a D16 without watch
but with all software functions like PWM/I2C/SPI/etc