The heartbeat or breathing circuit is a nice little LED project that makes use of a relatively simple circuit. We’ve used the LM358 op-amp in the previous project and to quickly recap: it’s an analog device whose output is the difference between the voltages at its two input terminals.
Transistor Q1 is used to control the LEDs and it will switch from the cut-off to linear, to saturation region depending on the voltage applied at its base terminal. Internally, the LM358 contains two op-amps which are both being used in this circuit. The op-amp section is designed to give us a ramp-like output that is fed to the base of the transistor which in turn controls the LEDs.
The positive terminal of U1G1 is connected to a voltage divider network consisting of R1 and R2. The values of R1 and R2 keep the positive terminal at a fixed voltage that is half of the supply voltage. The negative terminal is connected to the capacitor C1. When first switched ON, the output of U1G1 is HIGH and this causes the capacitor to start charging with the polarity as shown. The ramp waveform is in its rising phase which causes the LEDs to start glowing brighter.
The ramp output voltage is also fed back to the positive terminal of U1G2, while the negative terminal of U1G2 is held at the same reference voltage from the R1-R2 voltage divider network. The output of U1G2 will increase as the voltage difference between its input terminals increases. This output is connected to the left terminal of C1 and eventually, it will be at a higher potential compared to the right terminal. At this point, the output of U1G1 will start decreasing and the capacitor will start to discharge and charge with the opposite polarity. The output ramp voltage enters the falling phase, which causes the LEDs to fade away.
This ramp cycle repeats continuously and VR1 can be adjusted to change the ramp speed. Here’s what the assembled PCB looks like. Please be sure to place all the LEDs with the right polarity.