- Discrete LEDs
- Dot/Bar LEDs
- Matrix LEDs
- 7-Seg LEDs
- Serial -- Software
- Serial -- Hardware
- RS-232 via the MAX3232
- I2C -- EEPROM
- I2C -- DS1307 Real Time Clock
- 1-Wire -- DS18B20, Powered, Single-Drop
- 1-Wire -- DS18B20, Powered, Multi-Drop
- 1-Wire -- DS18B20, Parasitic, Multi-Drop
- TI Link Protocol -- Calculator Demo
- Infrared Communication
- MIDI -- Output Demo
- MIDI -- Input Demo
- MIDI to Analog Synth
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:
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