LED lamp state switching circuit
By using a frequency divider circuit and a combination of MOSFETs and transistors, the problem of the CPU GPIO port being unable to adjust the brightness of the LED was solved, enabling the switching of multiple brightness states of the LED, saving GPIO port resources and reducing costs.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Utility models(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-20
- Publication Date
- 2026-03-31
AI Technical Summary
In existing technologies, the CPU's GPIO port cannot output PWM signals and cannot automatically adjust the brightness of LEDs. The brightness of LEDs can only be adjusted by changing the output state of the GPIO port or modifying the current-limiting resistor.
By employing a frequency divider circuit, especially a two-way frequency divider circuit, and switching between high and low levels at the controller output terminals, combined with the circuit design of MOSFETs and transistors, the brightness of the LED lamp can be adjusted. The output signal of the two-way frequency divider circuit is used to control different current conduction states of the LED lamp.
It enables multiple brightness states of LED lights, saves CPU GPIO port resources, has a simple circuit structure and low cost, and meets the needs of normal use.
Smart Images

Figure CN224068829U_ABST
Abstract
Description
Technical Field
[0001] This utility model relates to the field of LED lamp control technology, and in particular to an LED lamp state switching circuit. Background Technology
[0002] One function of LED lights is as indicator lights on circuits and electrical equipment to show the working and positional status of the equipment. Indicator lights are typically used to reflect the working status of circuits (powered or de-powered), the working status of electrical equipment (running, stopped, or under test), and its positional status (closed or open).
[0003] The control diagram of an existing electronic device connected to an LED light is as follows: Figure 1 As shown, the negative terminal of the LED is connected to the CPU's GPIO port, which has a pull-up resistor R to ensure the voltage level does not float. The positive terminal of the LED is connected in series with a current-limiting resistor R and then to a 3.3V power supply. In this design, pulling the CPU's GPIO port high turns the LED off, and pulling it low turns it on.
[0004] However, the current connection method between LED lights and CPUs is problematic because some CPUs' GPIO ports lack PWM output functionality in their chip hardware design, and the software cannot implement PWM output for the GPIO ports either. As a result, the brightness of the LED lights cannot be automatically adjusted; the only way to turn the LED lights on or off is to change the output state of the GPIO ports. When it is necessary to modify the brightness of the LED lights, the current-limiting resistor R must be manually modified.
[0005] Therefore, this utility model proposes an LED lamp state switching circuit. Utility Model Content
[0006] The utility model of this invention provides an LED lamp state switching circuit, which mainly solves the problem that when the CPU's GPIO port cannot output a PWM signal, and the GPIO port PWM function output cannot be implemented in software, the brightness of the LED lamp connected to the CPU's GPIO port cannot be automatically adjusted. The LED lamp can only be turned on or off by changing the output state of the GPIO port, or the brightness of the LED lamp can be adjusted by modifying the resistance value of the current limiting resistor R.
[0007] This utility model proposes an LED lamp state switching circuit, including a controller, a frequency divider circuit connected to any output terminal of the controller, a control circuit connected to the output terminal of the frequency divider circuit, and an LED lamp connected to the output terminal of the control circuit.
[0008] When the controller outputs a high or low level and switches between high and low levels, the output of the frequency divider circuit outputs different level signals; the control circuit, based on the different level signals of the input signal, turns off the LED and lights the LED with different brightness.
[0009] Preferably, the frequency divider circuit is a frequency divider circuit of two.
[0010] Preferably, the divide-by-two circuit includes a D flip-flop;
[0011] The controller's output terminal is connected to the CLK terminal of the D flip-flop, and outputs the second output terminal of the divide-by-two circuit; the D flip-flop's... The terminal is connected to the D terminal; the Q terminal of the D flip-flop serves as the first output terminal of the frequency divider circuit.
[0012] Preferably, the D flip-flop is a rising edge triggered mode;
[0013] When the controller outputs a low level, both the first and second outputs of the frequency divider circuit are at a low level, and the control circuit controls the LED to turn off.
[0014] When the controller outputs a high level, both the first and second outputs of the frequency divider circuit are at a high level, and the control circuit controls the LED to be turned on by the first current.
[0015] When the controller output terminal switches to a low level, the first output terminal of the frequency divider circuit is at a high level and the second output terminal is at a low level, and the control circuit turns on the LED with a second current.
[0016] When the controller output terminal switches to a high level, the first output terminal of the frequency divider circuit is at a low level and the second output terminal is at a high level, and the control circuit turns on the LED with a third current.
[0017] The values of the first current, the second current, and the third current decrease sequentially.
[0018] Preferably, the control circuit includes MOSFET Q1, transistor Q2, MOSFET Q3, transistor Q4 and MOSFET Q5;
[0019] The source of the MOSFET Q1 is connected to the input voltage and is also connected to the gate of the MOSFET Q1 through the first protection circuit. The gate of the MOSFET is also connected to the collector of the transistor Q2. The drain of the MOSFET is connected to the source of the MOSFET Q5. The drain of the MOSFET Q5 is connected to the LED through the resistor R7.
[0020] The base of transistor Q2 is connected to the first output terminal of the frequency divider circuit through resistor R5, and the emitter is grounded;
[0021] The source of the MOSFET Q3 is connected to the input voltage and is also connected to the gate of the MOSFET Q3 through a second protection circuit; the gate of the MOSFET Q3 is also connected to the collector of the transistor Q4 and the gate of the MOSFET Q5; the drain output of the MOSFET Q3 is connected to the LED lamp through a resistor R2.
[0022] The base of the transistor Q4 is connected to the second output terminal of the frequency divider circuit through resistor R6, and the emitter is grounded;
[0023] The drain output of the MOSFET Q5 is connected to the LED lamp through resistor R7.
[0024] Preferably, the first protection circuit is an RC circuit, including a capacitor C2 and a resistor R3 connected in parallel;
[0025] The second protection circuit is an RC circuit, which includes a capacitor C1 and a resistor R4 connected in parallel.
[0026] Preferably, the control circuit further includes a resistor R1 connected in series between the drain of the MOS transistor Q1 and the LED.
[0027] Preferably, the controller includes a CPU;
[0028] The output terminal is a GPIO port.
[0029] As can be seen from the above, the following beneficial effects can be obtained by applying the technical solution provided by this utility model:
[0030] First, the state switching circuit proposed in this utility model realizes the frequency adjustment of the clock signal through a frequency divider circuit or even a frequency divider circuit, that is, the stable output signal of the GPIO port is adjusted to different frequencies and output signals as needed to realize the state switching of the LED light.
[0031] Secondly, the state switching circuit proposed in this utility model can control the LED light to switch between four states through the timing diagram of the input and output signals of the frequency divider circuit, which meets the user's regular use needs for LED lights. Moreover, its circuit structure is relatively simple and the cost is low.
[0032] Third, the state switching circuit proposed in this invention realizes the state adjustment of the LED light through only one GPIO port of the CPU, which greatly saves the CPU's GPIO port resources. Attached Figure Description
[0033] To more clearly illustrate the technical solutions in the embodiments of this utility model or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this utility model. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0034] Figure 1 This is a circuit diagram of the LED lamp state switching circuit in an embodiment of this utility model;
[0035] Figure 2 This is a circuit diagram of the frequency divider circuit in an embodiment of this utility model;
[0036] Figure 3 This is a timing diagram of the frequency divider circuit in an embodiment of this utility model;
[0037] Figure 4 This is a circuit diagram of the control circuit in an embodiment of the present invention;
[0038] Figure 5 This is a schematic diagram of the internal current flow of the control circuit when the LED light is turned off in this embodiment of the present invention;
[0039] Figure 6 This is a schematic diagram of the internal current flow of the control circuit when the LED light is at high brightness in this embodiment of the present invention;
[0040] Figure 7 This is a schematic diagram of the internal current flow of the control circuit when the LED light is lit in this embodiment of the present invention;
[0041] Figure 8 This is a schematic diagram of the internal current flow of the control circuit when the LED light is at low brightness in this embodiment of the present invention;
[0042] Figure 9 This is a diagram showing the relationship between the output signals of the LED lamp and the GPIO port in an embodiment of this utility model. Detailed Implementation
[0043] The technical solutions of the present utility model will be clearly and completely described below with reference to the accompanying drawings of the embodiments. Obviously, the described embodiments are only some embodiments of the present utility model, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present utility model without creative effort are within the scope of protection of the present utility model.
[0044] Currently, when the CPU's GPIO port cannot output PWM signals, and the GPIO port PWM function cannot be implemented in software, the brightness of the LED connected to the CPU's GPIO port cannot be automatically adjusted. The only way to control the LED's brightness is to change the output state of the GPIO port or modify the value of the current-limiting resistor R.
[0045] like Figure 1 As shown, in order to solve the above problems, this embodiment proposes an LED lamp state switching circuit, including a controller, a frequency divider circuit connected to any output terminal of the controller, a control circuit connected to the output terminal of the frequency divider circuit, and an LED lamp connected to the output terminal of the control circuit; when the controller output terminal outputs a low level and switches between high and low levels, the output terminal of the frequency divider circuit outputs different level signals; the control circuit, based on the different level signals of the input signal, turns off the LED lamp and lights the LED lamp with different brightness.
[0046] Preferably, in this embodiment, the frequency divider circuit is a two-way frequency divider circuit.
[0047] Preferably, in this embodiment, the controller is a CPU and the output terminal is a GPIO port.
[0048] Preferably, in this embodiment, the positive terminal of the LED is connected to the output terminal of the control circuit, and the negative terminal is grounded.
[0049] Preferably, in this embodiment, the control circuit illuminates the LEDs with different brightness levels, specifically by turning on the LEDs with different currents.
[0050] In this embodiment, a frequency divider circuit or even a frequency divider circuit is used to achieve a stable output signal from the GPIO port on the CPU to realize multiple level signals. Then, the LED light is turned on with different currents through multiple level signals, which can reduce the number of GPIO ports occupied and improve the applicability of GPIO ports.
[0051] like Figure 2 and Figure 3 As shown, more specifically, the divide-by-two circuit includes a D flip-flop; the output terminal of the controller is connected to the CLK terminal of the D flip-flop, and its output serves as the second output terminal B of the divide-by-two circuit; the D flip-flop's... The terminal is connected to the D terminal; the Q terminal of the D flip-flop serves as the first output terminal A of the divide-by-two circuit.
[0052] Preferably, in this embodiment, the D flip-flop and its connecting circuit can be replaced by a T flip-flop, and adjusted accordingly according to actual needs.
[0053] Preferably, in this embodiment, the D flip-flop adopts a rising edge triggering mode.
[0054] In this embodiment, the truth table of the frequency divider circuit can be summarized as shown in Table 1.
[0055] GPIO input low level high level low level high level A output 0 1 1 0 B output 0 1 0 1
[0056] Table 1
[0057] We can further summarize that there are four possible scenarios for state switching circuits:
[0058] (1) When the output terminal of the controller outputs a low level, the first output terminal A and the second output terminal B of the frequency divider circuit are both at a low level, and the control circuit controls the LED to turn off.
[0059] (2) When the output terminal of the controller switches to a high level, that is, when there is a rising edge, the first output terminal A and the second output terminal B of the frequency divider circuit are both at a high level. The control circuit controls the LED to be turned on by the first current, and the LED is bright.
[0060] (3) When the output terminal of the controller switches to a low level, that is, when there is a falling edge, the first output terminal A of the frequency divider circuit is at a high level and the second output terminal B is at a low level. The control circuit turns on the LED with the second current, and the LED lights up.
[0061] (4) When the output terminal of the controller switches to a high level, that is, when there is a rising edge, the first output terminal A of the frequency divider circuit is low and the second output terminal B is high. The control circuit turns on the LED with the third current, and the LED is low-brightness.
[0062] like Figures 4-9 As shown, more specifically, the control circuit includes MOSFET Q1, transistor Q2, MOSFET Q3, transistor Q4, and MOSFET Q5. The source of MOSFET Q1 is connected to VCC and is also connected to the gate of MOSFET Q1 through a first protection circuit. The gate of MOSFET Q1 is also connected to the collector of transistor Q2. The drain of MOSFET Q1 is connected to the source of MOSFET Q5. The drain of MOSFET Q5 is connected to the LED through resistor R7. The base of transistor Q2 is connected to the first output terminal A of the frequency divider circuit through resistor R5, and its emitter is grounded. The source of MOSFET Q3 is connected to VCC and is also connected to the gate of MOSFET Q3 through a second protection circuit. The gate of MOSFET Q3 is also connected to the collector of transistor Q4 and the gate of MOSFET Q5. The drain output of MOSFET Q3 is connected to the LED through resistor R2. The base of transistor Q4 is connected to the second output terminal B of the frequency divider circuit through resistor R6, and its emitter is grounded. The drain output of MOSFET Q5 is connected to the LED through resistor R7. Preferably, Q1, Q3 and Q5 are all PMOS transistors.
[0063] The first protection circuit is an RC circuit, including a capacitor C2 and a resistor R3 connected in parallel; the second protection circuit is an RC circuit, including a capacitor C1 and a resistor R4 connected in parallel. In this embodiment, the first and second protection circuits are used to pull up the gate voltage at the moment VCC is powered on to prevent PMOS transistors Q1 and Q3 from being mis-turned on, and can also pull up the gate voltage when transistors Q2 and Q4 are turned off to turn off PMOS transistors Q1 and Q3.
[0064] The control circuit also includes a resistor R1 connected in series between the drain of the MOSFET Q1 and the LED.
[0065] Preferably, in this embodiment, resistors R1, R2, and R7 are used as current-limiting resistors. Preferably, but not limited to, in this embodiment, R1 = 75Ω, R2 = 560Ω, R3 = 10kΩ, R4 = 10kΩ, R5 = 1kΩ, R6 = 1kΩ, R7 = 33Ω, C1 = 100nF, and C2 = 100nF.
[0066] In this embodiment, the four operating states of the state switching circuit are as follows:
[0067] (1) As Figure 5 As shown, when the controller outputs a low level, both the first output terminal A and the second output terminal B of the frequency divider circuit are at a low level. At this time, the bases of transistors Q2 and Q4 are pulled low, so transistors Q2 and Q4 are not conducting. As a result, the gates of MOSFETs Q5, Q1, and Q3 are pulled high by pull-up resistors R3 and R4, respectively. Therefore, MOSFETs Q5, Q1, and Q3 are not conducting. At this time, no current flows through the LED, so the LED is in the off state.
[0068] (2) Figure 6 As shown, when the controller's output terminals switch to a high level, both the first output terminal A and the second output terminal B of the frequency divider circuit are at a high level. Current flows into the bases of transistors Q2 and Q4, causing them to conduct and pull their collector voltages low. This pulls down the gates of MOSFETs Q1, Q3, and Q5, turning them on. The source of MOSFET Q5 is connected to VCC through MOSFET Q1, thus turning Q5 on as well. At this time, current flows through current-limiting resistors R1, R2, and R7 to power the LED. The equivalent resistance of the current-limiting resistors is the parallel resistance of the three resistors. Assuming the voltage across the LED when it is on is Vd, the total current flowing through the LED is...
[0069]
[0070] In this working state, the series resistance of the LED reaches its minimum value, the current flowing through it reaches its maximum value, and the LED is at its brightest, which is the high-brightness state.
[0071] (3) Figure 7 As shown, when the controller's output terminals switch to a low level (i.e., a falling edge exists), the first output terminal A of the frequency divider circuit is high, and the second output terminal B is low. Current flows into the base of transistor Q2, but not into the base of transistor Q4. Therefore, transistor Q2 conducts, pulling its collector voltage low, while transistor Q4 does not conduct. Consequently, the gate of MOSFET Q1 is pulled low, while the gates of MOSFETs Q3 and Q5 are pulled high by their pull-up resistors. Thus, only MOSFET Q1 conducts, while MOSFETs Q3 and Q5 do not conduct. At this time, only current flows through the current-limiting resistor R1 to power the LED. The total current flowing through the LED is...
[0072]
[0073] In this working state, the series resistance of the LED is slightly larger than the minimum value Rmin, and the current flowing through it is smaller than the maximum value. Therefore, the LED is dimmer than in the high-brightness state and belongs to the medium-brightness state.
[0074] (4) Figure 8 As shown, when the controller's output terminals switch to a high level (i.e., a rising edge exists), the first output terminal A of the frequency divider circuit is low, and the second output terminal B is high. No current flows into the base of transistor Q2, while current flows into the base of transistor Q4. Therefore, transistor Q2 is not conducting, while transistor Q4 is conducting, pulling its collector voltage low. Consequently, the gates of MOSFETs Q3 and Q5 are pulled low, while the gate of MOSFET Q1 is pulled high by the pull-up resistor. Since MOSFET Q1 is not conducting, MOSFET Q5 also cannot conduct. Thus, only MOSFET Q3 is conducting, while MOSFETs Q1 and Q5 are not conducting. At this time, only current flows through the current-limiting resistor R2 to power the LED. The total current flowing through the LED is:
[0075]
[0076] In this operating state, the series resistance of the LED reaches its maximum value, and the current flowing through it reaches its minimum value. Therefore, the LED is dimmer than the medium brightness state, which is the low brightness state.
[0077] In summary, this embodiment uses three PMOS transistors (Q1, Q3, and Q5) and three resistors (R1, R2, and R7) to form a circuit that can control the switching of the parallel resistor state. Two level signals from a frequency divider circuit control the conduction state of the PMOS transistors. The frequency divider circuit generates four different output level combinations based on the high and low level signals from the GPIO port. This, in turn, controls the conduction state of the three PMOS transistors by controlling the conduction state of the NPN transistors (Q2 and Q4), thereby switching the total resistance value of the three current-limiting resistors and adjusting the current flowing through the LED. This invention can be used not only in consumer electronics but also in industrial control, aerospace, and automotive electronics. Furthermore, besides being built with discrete components, this invention can be packaged into a chip using integrated circuit design, further reducing circuit space.
[0078] The embodiments described above do not constitute a limitation on the scope of protection of this technical solution. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the above embodiments should be included within the scope of protection of this technical solution.
Claims
1. An LED lamp state switching circuit, characterized in that: it comprises a controller, a frequency division circuit connected to any output terminal of the controller, a control circuit connected to the output terminal of the frequency division circuit, and an LED lamp connected to the output terminal of the control circuit; when the output terminal of the controller outputs low level and switches output high-low level, the output terminal of the frequency division circuit outputs different level signals; and the control circuit controls the LED lamp to be turned off and turned on at different brightness based on the different level signals of the input signals.
2. The LED lamp state switching circuit according to claim 1, characterized in that: the frequency division circuit is a frequency division circuit.
3. The LED lamp state switching circuit according to claim 2, characterized in that: the frequency division circuit comprises a D flip-flop.
4. The LED lamp state switching circuit according to claim 3, characterized in that: the D flip-flop is in rising edge trigger mode; when the output terminal of the controller outputs low level, the first output terminal and the second output terminal of the frequency division circuit are both low level, and the control circuit controls the LED lamp to be turned off; when the output terminal of the controller switches output high level, the first output terminal and the second output terminal of the frequency division circuit are both high level, and the control circuit controls the LED lamp to be turned on at a first current; when the output terminal of the controller switches output low level, the first output terminal of the frequency division circuit is high level and the second output terminal is low level, and the control circuit controls the LED lamp to be turned on at a second current; when the output terminal of the controller switches output high level, the first output terminal of the frequency division circuit is low level and the second output terminal is high level, and the control circuit controls the LED lamp to be turned on at a third current; and the current values of the first current, the second current and the third current decrease in turn.
5. The LED lamp state switching circuit according to claim 4, characterized in that: the control circuit comprises a MOS tube Q1, a triode Q2, a MOS tube Q3, a triode Q4 and a MOS tube Q5; the source of the MOS tube Q1 is connected to an input voltage, and the gate of the MOS tube Q1 is connected to the collector of the triode Q2 through a first protection circuit; the drain of the MOS tube Q1 is connected to the source of the MOS tube Q5; the drain of the MOS tube Q5 is connected to the LED lamp through a resistor R7; the base of the triode Q2 is connected to the first output terminal of the frequency division circuit through a resistor R5, and the emitter is grounded; the source of the MOS tube Q3 is connected to an input voltage, and the gate of the MOS tube Q3 is connected to the collector of the triode Q4 and the gate of the MOS tube Q5 through a second protection circuit; the drain output of the MOS tube Q3 is connected to the LED lamp through a resistor R2; the base of the triode Q4 is connected to the second output terminal of the frequency division circuit through a resistor R6, and the emitter is grounded; and the drain output of the MOS tube Q5 is connected to the LED lamp through a resistor R7. The output terminal of the controller is connected to the CLK terminal of the D flip-flop and outputs the second output terminal of the frequency division circuit; the D terminal of the D flip-flop is connected to the D terminal; and the Q terminal of the D flip-flop is used as the first output terminal of the frequency division circuit. The output terminal of the controller is connected to the CLK terminal of the D flip-flop and outputs the second output terminal of the frequency division circuit; the D terminal of the D flip-flop is connected to the D terminal; and the Q terminal of the D flip-flop is used as the first output terminal of the frequency division circuit. 6.The LED lamp state switching circuit according to claim 5, characterized in that: the first protection circuit is an RC circuit comprising a capacitor C2 and a resistor R3 connected in parallel; the second protection circuit is an RC circuit comprising a capacitor C1 and a resistor R4 connected in parallel. 7.The LED lamp state switching circuit according to claim 6, characterized in that: the control circuit further comprises a resistor R1 connected in series between the drain of the MOS transistor Q1 and the LED lamp. 8.The LED lamp state switching circuit according to any one of claims 1 to 7, characterized in that: the controller comprises a CPU; the output terminal is a GPIO port.