Breathing LED Sleep Indicator for Microcontroller Projects

guclusat

Tanınmış Üye
Süper Moderatör
Recently, I wanted to build a Sleepy-LED Eye as an add-on indicator for a small personal project. My idea is a near-replica of the iconic breathing pattern used for the “sleep” indicator in Apple computers. Naturally, any maker can recreate the effect easily with the help of a microcontroller (and a few lines of pulse-width modulation code), but my design is based on a few extremely cheap discrete electronics components — yes, 100% analog!

Design description
First, let’s take a look at the schematic. The design is centered entirely around one popular dual-operational amplifier LM358 (IC1) to slowly fade a green light-emitting diode (LED1) in a special pattern (the so-called breathing effect). The circuit runs well with a regulated supply voltage of 5 V; higher-level voltages are not recommended. If the two-way jumper (JP1) in the circuit is in “test” mode, the circuit will work as a standalone indicator. But moving the jumper position to “normal” mode, a TTL high-logic signal input is required to enable (EN) the indicator. This option is added deliberately so that we can enable/disable the Sleepy-LED Eye using the existing microcontroller (uC) in a project — just one free I/O port of the concerned uC is needed there. For example, one I/O port of the uC can be programmed to wake-up the Sleepy-LED Eye only when the system is in its standby state.

1-Sleepy-LED-Eye-Schematic.webp

As you may have noticed, the circuit configuration closely resembles the classic idea commonly considered for a basic triangular sweep generator—i.e., the Schmitt trigger integrator to make a triangle wave. With an oscilloscope, we can see a square wave at the output (Pin 7) of the second op-amp (B). Similarly, if we probe the oscilloscope on the output (Pin 1) of the first op-amp (A), the scope trace looks something like the one shown below (subject to realistic limits, the triangle wave may not strictly obey the design math, but it’s nice for the breathing pattern).

The BC547 transistor (T1) works as the “power switch” of the circuit, configured like a high-side driver. Such a configuration with an NPN transistor is obviously not a good practice, but here, it’s a good fit. The DC voltages indicated in the schematic were measured with a precision digital multimeter probed into various circuit points with respect to the ground (GND) rail (JP1 in test mode). It’s observed that the maximum current consumption of the entire circuit (breadboard prototype) is well below 3 mA (it actually swings in a 1.2-mA to 2.5-mA scale). Note that the 100-Ω resistor (R8) limits the operating current of LED1 — a low-current, 5-mm, high-bright green LED (see my quick test video).

Construction & quick test
The circuit can be constructed on a small scrap of prototyping board. The construction is not at all difficult because no SMD parts are used. As usual, start by fitting the lowest parts, followed by the taller components. The IC should be fitted in an eight-pin DIL socket. After construction, power the circuit up with a 5-V regulated DC supply and watch the performance. If breathing does not feel very natural, try to tweak the value of R6 (15K–39K). Because of component tolerances, you may also need to alter the value of R7 (47K–68K). Besides, depending on the LED that you use, it might be necessary to experiment with the value of R8. Nowadays, you can get almost all components in SMD packages. When using SMD parts and a customized PCB, the entire circuit can be built very compactly.



Theory talk
A noteworthy fact is that Apple has a patent on the sleep indicator’s breathing pattern used on all of their computers. The patent claims that the breathing pattern is a simple sine curve, but it surely has a more complex nature than that. Basically, when it comes to ramps and delays in analog electronics, we think about the typical charging and discharging process of a capacitor. The central component of the given design is also the same capacitor (CI) but with two op-amps (IC1) as comparator and integrator. In principle, the output waveform of an integrator will be triangular if its input is square-wave. That means that a triangular wave can be generated just by combining one square-wave generator and one integrator-ramp generator. See, there’s also a wondrous trick used to define the boundaries (upper and lower threshold) of the triangle wave. Took enough math in school?



Finally, there are certainly better ways of making a breathing lamp. I’ll leave it (including the rest of the theory part) as a homework exercise for the reader. By the way, my analog approach is simply because I had all of the parts lying in my drawer. Beyond that, I do love microcontrollers, but I pick analog whenever possible to encourage novices to learn how to play with analog electronics!
 
Geri
Yukarı