The project uses an STC15W104 microcontroller as the main control chip, and adjusts the light brightness by using a button-based timer to adjust the 25kHz pulse duty cycle. Links to the program and simulation will be provided at the end of this document.
A lithium battery charging circuit was added, using a TP4054 charging circuit (tested with a yellow LED, it can achieve normal light-off upon completion of charging without a pull-up resistor). However, testing revealed that the TP4054 in this package generates significant heat under normal power; adding a pull-down resistor to the PROG port can reduce the charging current (roughly estimated, around 5KΩ is just right). The voltage is 4.2V upon completion of charging.
The light uses 3528 high-brightness warm white LEDs with S8050 transistors, paired with two sets of LEDs, controlled by two I/O ports of the microcontroller. A 56Ω resistor is sufficient for the LEDs; the 200Ω resistor in the schematic is unnecessary. A software delay generates a PWM signal to control the duty cycle and adjust the LED brightness. A long press of the button turns on the LED and adjusts its brightness; a short press turns it off. Press and hold to the highest brightness setting, then the LED will turn off. Release the button to turn it on again and maintain the highest brightness. For detailed instructions, search for the Bilibili user "被玩疯的安培易爆" (The Ampere Explosion is Played Like Crazy).
Finally, let's calculate the costs. First, color silkscreen printing and prototyping costs 30 yuan; LEDs, resistors, and capacitors (smallest selling unit) total 3.84 yuan; 5 Type-C female connectors cost 1.8 yuan; 5 STC15W104 microcontrollers cost 8.65 yuan; 5 TP4054 charging chips cost 2.05 yuan; and 5 S8050 transistors cost 1.15 yuan. Five sets total 47.49 yuan. Compared to the more complex external circuitry and touch chip dimming circuit, the total cost is significantly reduced... (It's recommended to buy from Taobao for even greater savings).
As I'm not good at uploading programs to Gitee, both the program and simulation are uploaded to Baidu Cloud, and are permanently available.
Link: https://pan.baidu.com/s/1WrjlLxNMpj4MnAjQDqkzEQ?pwd=Ampe Extraction code: Ampe