What's the perfect gift for the special someone that puts up with a soldering iron in the kitchen and little bits of wire underfoot? How about this touch activated, pulsating LED heart? This geeky Valentine's Day card pays homage to the musical greeting cards that are popular this time of year. This isn't just for Valentine's Day -- it's a simple heart, so give it to your loved one any time of the year. You can also make your own shapes using the same basic circuit.
A microcontroller pulses the LED heart for a few seconds when the touch switch is activated. After the fade routine, the microcontroller enters a power saving sleep mode. The card runs from a single button cell battery. A battery should last a long time because little power is consumed in the sleep state.
All the files you need to make your own LED valentine are included in the project archive. Download it here.
An old, cheap (~$2) PIC 16F684 serves as the brain of the card. It will run perfectly from a 3-volt button cell battery, or any 2-6 volt supply. I would have preferred to use the 8 pin 12F629 (~$1). For a one-off project like this, though, the 14 pin PIC is fine. Some will correctly suggest that a PIC is overkill for this project -- it's better done with a 555 IC, and a handful of resistors, capacitors, transistors, and gumption. Possibly true, but it was faster and easier to use a PIC.
The PIC has an internal crystal oscillator. We'll run it at 500kHz to save a bit of power. It doesn't help too much -- the LEDs are the real gas guzzlers here. At full speed, the PIC uses less power than a single LED.
We need to decouple the single pair of supply pins with a 0.1uf capacitor, and add a resistor and diode for the programming header. Look for more about programming in my next post.
The LEDs are dimmed using a hardware pulse-width modulator (PWM) on the PIC (PORT C, pin 5). The PWM isn't strong enough to directly power all the LEDs; instead, it switches the ground of the LEDs through a transistor. This is the same method used in the RGB color changer and the analog gauge projects.
I used 14 red surface mount LEDs (0806) to outline the heart. My LEDs have a 2.0 forward voltage, and the circuit runs at 3 volts, so a 100 ohm resistor puts about 15 ma of current through the LEDs. Calculate your own resistor using a website like this.
Tiny surface mount transistors switch more than a PIC pin, but not by a lot -- usually about 100ma. One transistor will switch about 5 LEDs with a small safety margin. The card's 14 LEDs are arranged in two groups of 5 and one group of 4.
A touch-sensitive pad triggers the beating heart. The PIC is usually in sleep mode, but a signal from the touch switch circuit will wake it. The switch is based on a simple PNP transistor design that uses almost no power when it's idol. The "switch" part of the transistor is brought out to a pad on the PCB. A tiny charge travels over the skin and into the surrounding ground plain when the pad is touched. The transistor amplifies this and puts a bunch of current on the PIC pin, waking it from sleep mode. One resistor (R1) on the touch pad protects the transistor (Q1) from accidental short-circuits. Another resistor (R2) shunts any transistor leakage to ground, preventing false triggers.
A full sized circuit diagram ".PNG" is included in the project archive.
The circuit board is designed with Cadsoft Eagle, you can download a freeware version. The large heart is a restricted area in Eagle, but 'Touch Here' was added to the PDF version -- something to remember if you export your own board. All parts are surface mount, except the battery holder and the programming header. This worked fine -- its better to have the battery on the back. Don't forget the three jumper wires.
Part list -- Part / Type (size) See a full-sized placement image in the gallery and project archive.
C5 / 0.1uf (0805)
D1 / 1n4148 (SOT-23) *I used BAS16 85V/200ma
This simple project is compiled using mikroBasic. You can download a 2k limited demo for free. The source code, and a compiled .hex file, are included in the project archive. This is a simple project, so working in Basic might help some absolute beginners.
The software is very rudimentary, less than 100 lines. It works like this:
An interrupt is generated by the touch switch connected to port A, pin 2, that wakes the PIC from sleep mode.
The PIC fades the heart a few times using the hardware pulse-width modulator on port C pin 5.
After a few seconds, the PIC returns to sleep mode and waits for another switch interrupt.
The 16F684 can be swapped for your favorite microcontroller. It must have at least two IO pins: preferably one with a hardware PWM, and one with a "wake from sleep on interrupt" feature. I mentioned the cheap PIC 12F629 earlier. Low pin-count ATMEL AVRs and TI MSP430 chips are also available for under a buck. Even I think a 16-bit MSP430 Valentine's Day card is overkill, but how can you beat the price?
This was a fun first version, but I'd make a ton of changes in a new design. The LEDs are really bright at 15ma, larger-value resistors would cut their intensity while also saving power. I'd convert the resistors to 0805 size if Iordered new parts for this project. The programming header is ugly – an edge connector or programming pads would be much more attractive.
A touch-activated, pulsating LED heart isn't just for Valentine's Day - you can give it to your special someone any time of the year!
Happy Valentine's Day from DIY Life.
Links New to electronics? Here are some introductory tutorials to help you get started.