LED Bar Graph with Single Port Pin

It's so easy to fall into a digital frame of mind and not remember just how useful analog can be. Here's a prime example. I hate that hackneyed phrase "thinking outside the box," but perhaps this comes close to illustrating it: using the analog capabilities of the PIC with an analog chip to grossly simplify both the hardware and software in a project. To wit, we can bring things down to a single port line, while simultaneously making the program laughably simple. The secret is the LM3914, which is an LED bar/dot graph driver. It's supposed to monitor an analog voltage and light appropriate elements on a display, and that's what we'll do here. Only, the analog voltage is provided by the PIC!

Maybe take at look at the schematic first:

Begin by noticing how simple the hardware is. All of the LED drivers are contained within the LM3914 with plenty of power to spare. Then observe that this chip is driven by a single line (pin 5). As mentioned, this is a voltage sensing input.

But lo! The PIC16F88 can actually output its internal DAC level at its own pin 1. And that's the secret. The output swings from 0V to 2.08V under register control (CVRCON). More than enough resolution to reliably handle the ten elements of the bar graph display. So don't let the analog nature of things dissuade you from this rather nonstandard approach.

But wait, there's more! No Ginsu knives, but with switch S1 you can also choose between bar or dot mode, free of charge.

I mean, this is crazy simple and perhaps the best approach for driving an LED bar graph. No Darlingtons, no buffers, and just one single, solitary port line used!

Click to get the source code.
Click to get the schematic PDF.

Next Project: LED Matrix -- Single Character

No comments:

Post a Comment