Hello!
I want to create simple driver for XPG2 led for bicycle running from one 18650 battery.
The first problem: i am not familiar with electronic schematics, i am a microcontroller’s programmer, so i decided to ask help here.
I hope that everything has already been invented before me, so may be anyone knows a good and simple schematic of PWM’s controlled led and microcontroller (ATMEL for example)?
I have searched the Internet, and discovered that all of such schematics consist of mosfet and microcontroller, which controls led by PWM to this mosfet.
I want to use ATTINY85 as MCU, cause i know it well.
And the second problem - it is the charger. I knew the very simple schematic based on tp4056 chip. But i want to control internal charger and battery by MCU.
I expain why:
1. if led is on and no external power is attached - MCU controls the discharge of internal battery and generate PWM to the XPG2 and controls LED temperature - it is normal mode
2. if led is on and external power is attached by external battery near 3.7v - internal charger and battery must be switched off, now MCU controls external power discharge (like it does in 1) - it is external battery mode
3. if led is on and external power is attached and it is near 5v - internal charger and battery must be switched off, microcontroller stops to control the discharge and simply control only led - external power mode
4. if led is off and external power is attached and it is near 5v - charging of internal battery is started - it is charge mode
How can i achieve it? And i am very limited of PCB size (because of case of the flashlight).
What is the better mosfet for XPG2? SI2303 is good enought for it?
P.S. thank you for any information
P.P.S. sorry for my bad english