Skip to main content
These old analog gauges were in a one-dollar junk box at the market. Before there were LCD screens in everything, before LEDs, data was shown on these.

In a sort of retro mash-up, we'll make a USB device that displays PC status info on these gauges. The gauges can show CPU and memory usage, processor voltage -- just about any numerical data typically displayed on small HD44780 based LCD character displays commonly used in PC case mods.

You'll find all the details and project files after the fold. Check out the podcast for an overview of the project.

USB analog gauge overview(click thumbnails to view gallery)

Analog gaugesPulse-width modulation on an analog gaugeDriver and analog gaugesRendering of the circuit board

Grab the project archive for the circuit, PCB, firmware, and more.


This design is closely related to the USB color changer project.

Instead of blinking LEDs, though, it pulses power to an analog gauge. The ratio of "on" and "off" pulses determines the needle position -- this is called pulse-width modulation (PWM). A signal that is on 75% of the time will read 75% on the gauge. This pulsed (or modulated) signal is smoothed by the magnetics inside the gauge. Analog gauges have a lot of inductance, so they give a steady reading without noticeable twitching.

Data for the gauges will be collected by LCD Smartie, an open source MS Windows program intended to drive small character LCD panels. We can finesse LCD Smartie to send raw data through a USB port to the gauge controller board in a format we can use. These readings will then be converted into a signal that positions the gauge needle.

This design uses surface mount parts, resulting in a very small circuit board that can be tucked inside a computer case. For a similar through-hole design, see the USB color changer project.

A PIC 18F2550 is used for USB connectivity, the support hardware is detailed in the USB color changer project. The gauges will always be connected to a PC, so I configured the PIC for USB power. This is a bit different than the USB color changer, a self powered device that uses a pin to sense the USB connection. The gauge driver doesn't need this pin because it's only powered when a USB cable is attached.

The gauges
Analog gauges don't directly measure a voltage, they measure a small fraction through a resistor. The voltage meter in the picture is graduated to 600 volts, but reaches 100% at about one volt. A large-value resistor is used to reduce the measured voltage to an acceptable level. A new gauge should have a datasheet that lists the reduction ratio.

If you scrounge old gauges without documentation, you'll have to experiment to find the correct resistor. I started by connecting my gauge to a power supply (2.5 volts) through a 500K ohm resistor -- barely any movement. I cut the resistance in half until I found a value that held the needle at 100%. A variable resistor (potentiometer) would help dial in the exact calibration, but with the immense variation among gauges it would be impossible to specify a part. Instead, I just used regular through-hole resistors connected directly to the gauge.

A PIC pin outputs a positive voltage, like the + (positive) terminal of a battery. It can drive a gauge directly, as shown in the diagram. This won't work with gauges that need more than the 25ma of current/5 volts provided by a PIC. A much more robust configuration is to switch the gauge ground (-) through a transistor (Q1 in the diagram below). This lets us connect several gauges on the same output, or drive gauges that need a power supply not provided by the PIC.

Gauges are usually a light load. We can use a simple (and tiny) transistor to switch them. The transistor I used will switch loads up to 100ma -- dozens of gauges, but only 5 LEDs. The transistor (Q1 in the diagram above) requires a resistor (R3) to limit current from the PIC pin. I also included a spot for a capacitor (not shown) that will smooth the modulated signal - a low pass filter. Install this capacitor to eliminate twitching in ultra-sensitive gauges -- I didn't need to install them. It might be easier to attach a capacitor directly between the gauge leads if needed (see C1 in the "Connecting the Gauge" diagram below).

2.5 volt power supply
A separate 2.5 volt supply powers the gauges. An independent supply is a bit excessive, but there are three good reasons to do this. First, the USB spec allows a supply from 4.75-5.25 volts. This variation means that every computer would need different gauge resistors if we used the USB supply. Second, if you've ever watched your power supply stats you know that voltages can "sag", or decrease, under heavy system loads. Gauges connected directly to the USB supply would bounce along with the sag. Finally, many gauges require less than 1 ma of current at less than 1 volt, a ~5 volt supply is overkill. I used an LM317 adjustable regulator to convert the 4.75-5.25 volts from the USB port to a steady 2.5 volts. Two 240 ohm resistors set the 2.5 volt output, you can calculate resistors for custom voltages using a site like this.

Gauge Connection
This diagram shows how to connect a gauge to the circuit board. The positive terminal of the gauge, usually labeled with a "+", is connected to a (2.5 volt) power supply through a limiting resistor (R1). Recall that we determined this resistor earlier using the datasheet or trial and error. The ground terminal of the gauge, usually labeled "-" or "GND", connects to one of the gauge drivers. Really sensitive gauges might need a capacitor between the two terminals to smooth the modulated signal.

Hardware Pulse-Width modulator (PWM)
I thought it would be clever to use a hardware PWM in this project to contrast the software PWM in the USB color changer. The PIC 18F2550 has two hardware PWMs that generate a gauge-driving pulse automatically, without any software or interrupts. Both of the output transistors are connected to pins with hardware PWMs (port C, pin 1 and 2). Here's a shortcut calculator to find the PWM register values, or read the Microchip PIC Mid-Range Manual [pdf!]. In the end, the software PWM was a better choice -- I'll discuss this more in the firmware section.

Click here for a full size image of the circuit.

USB analog gauge circuit(click thumbnails to view gallery)

Driving an analog gaugeUSB analog gauge driver circuitConnection DiagramAnalog gauge resistor

PCB Layout

The circuit and PCB were made using Cadsoft's Eagle Layout Editor. These files are in the /pcb folder of the project archive. A freeware version of Eagle is available for download.

This board is all one layer, with no jumper wires. Parts are mostly surface mount, but the pin headers and USB socket are through-hole. Watch the USB socket orientation - its on the bottom, opposite the PIC, to better accommodate one-sided boards. If you were to accidentally install the socket on the SAME side as the PIC, it would probably damage the PIC or your PC.

The PIC is a very large SO size chip package, similar to a DIP (through-hole) chip with the legs pushed out. Resistors and capacitors are specified in mixed 1206 and 0805 sizes. I'm working towards all 0805 sized designs, but I still have tons of 1206 resistors. The smallest parts are the SOT-23 transistors and diodes. These are intimidating, but really no problem at all. My favorite way to solder surface mount parts (all the way to 0402):
  1. Apply a bit of liquid flux to every solder pad.
  2. Put a dot of solder on one pad.
  3. Hold the part in place with tweezers.
  4. Heat the part lead and solder dot, hold the part flush to the board when the solder melts.
  5. Remove your iron but continue holding the part in place tweezers.
  6. Release your tweezers.
  7. Now solder the rest of the leads.
  8. Breathe! It's not as pretty as machine placement, but it works.
There are some great soldering videos and tutorials in the links below.

USB analog gauge driver PCB(click thumbnails to view gallery)

Component placement -- top and bottomComponent placement, no traces.Component placement -- top onlyComponent placement -- bottom layer.Circuit board, traces only.

Part list

Part - Value (Size/Package)

C1,2 - 27pF (0805)
C3,4,5,6,9,24,25 - 0.1uF (0805)

D1 - 1n4148 (SOT-23) *I actually used BAS16 85V/200ma

R1 - 10k ohm (1206)
R2 - 330 ohm (0805)
R3,4 - 100 ohm (1206)
R8,9 - 240 ohm (0805)

IC1 - PIC18LF2550-I/SO (SO-28W)
IC2 - LM317 (SOT223)
ICSP - 0.1" pin header, 5 pins
PORTB - 0.1" pin header, 6 pins
LED - LED (1206)
Q1 - 20MHz crystal (HC49UP)
Q3 - NPN transistor (SOT23) *I used BCW60D 32V/100ma
X1 - USB female 'B' connector (through hole)
X2 - 3 terminal screw clamp

USB analog gauge(click thumbnails to view gallery)

Unsoldered PCBDrive board topDriver board back


The firmware is compiled in Microchip's MPLAB with the PIC C18 compiler. MPLAB is free, you can grab it here. Evaluation and free student editions of the C18 compiler are available to download here. A compiled .hex file, ready to program to a PIC, is included in the project archive.

See how I program the PIC, and build your own programmer, in my PIC programming tutorial.

The firmware uses Microchip's USB framework. This is the same framework used in the RGB color changer project. Read more about compiling the framework there.

Interface protocol

The actual interface protocol, how values are put on the gauge, is dictated by the software we're using. LCD Smartie is an open source MS Windows program intended to drive small character LCD panels. It retrieves system information like CPU load, memory usage, current playlists, and more. It has a 'test driver' that will throw data down a serial port -- this is perfect because the USB firmware emulates a serial port. We can configure LCD Smartie to skip the typical HD44780 control commands, and just send raw system status info through the USB port. For example, in this setup:

the first line is my CPU usage followed by the upper-case letter 'B'. The second line is my memory usage followed by the upper-case letter 'A'. LCD Smartie sends command sequences every time one of the values changes. Take this example sequence:


This is a super simple protocol -- the value (100) followed by an identifier (A/B). The value is just a whole number percent between 0 and 100. The identifier tells the PIC which gauge gets the value. That's it! No newline characters, such as enter or return, are needed. The example sequence would set gauge A to 100%, then 80%, and finally 82%. The firmware receives the values as ASCII characters and decodes them to a usable form.

Software PWM
I had intended to use the PIC hardware to create a PWM signal. This is fine solution, but there are a ton of reasons that using the software PWM was easier. The soft PWM can to expand beyond 2 gauges. The PIC PWM is a bit complicated -- a period of 100 units and a duty cycle of 50 units doesn't always yield a 50% duty cycle. LCD Smartie sends data on a scale of 0-100 -- its easy to change the software PWM to work on 100 ticks instead of 255. This saves us from doing any messy divide operations on a tiny processor, or creating a lookup table. Read more about software PWM in the USB color changer project.


A compiled firmware .hex is included in the project archive. I included the modified source files, rather than the whole project. The easiest way to work with the source is to install the Microchip USB framework (I used version 1.2) and copy the modified source files over the fresh installation. For more info on this procedure see, yes, the USB color changer. These files were changed:
  • MCHPFSUSB\fw\Cdc\18f2550(i).lkr
    • linker files for the 18f2550, use the 'I' version when using a debugging tool like the ICD2.
  • MCHPFSUSB\fw\Cdc\io_cfg.h
    • Set custom USB LED pin.
  • MCHPFSUSB\fw\Cdc\autofiles\usbcfg.h
    • Enabled USB power mode.
  • MCHPFSUSB\fw\Cdc\user\user.c
    • Software PWM, USB interface.

Testing the USB connection
Check out the previous USB project for procedures to connect to a PC for the first time, get the COM port number, and setup Windows Hyperterminal.

Open Hyperterminal and start a connection to the device.
To set gauge A to 100%, type:
  • 100A
That's it, no enter or return, just "100A". The device will respond with "0" and the gauge should change positions.

To set gauge B to 50%, type:
  • 50B
The device will respond with "0" and the gauge should change.

Configure LCD Smartie
The LCD Smartie default settings send a bunch of unnecessary positioning data. In this section we'll configure it to send data through the USB port using our simple protocol instead. Grab LCD Smartie here. Read the complete LCD Smartie "test driver" documentation if you want the dirty details.

1. Extract LCD Smartie to a folder.
2. Find config.ini in the LCD Smartie folder, open it with an editor.
3. Paste this configuration information for our custom "screen" after the last line of the "[General Settings]" section:

[Test Driver]

4. This empty configuration files tells LCD Smartie that it shouldn't use any control characters or extra junk that we don't need.
5. Save the configuration file.

Next, we'll configure LCD Smartie with a hypothetical "screen" and start sending data to the gauges.

Click for a full sized view of the configuration screen.
  1. Open LCD smartie.
  2. Click the "Screens" tab and find the "Display settings" box.
  3. Click the small "Plugin" tab.
  4. For the "Display Plugin" choose "testdriver.dll".
  5. Change the "Startup Parameters" COM port number to the COM port assigned to the virtual serial port by Windows (see the color changer project for instructions).
  6. Next, click the small "Screen" table below the "Plugin" tab.
  7. Set the "LCD size" to "2x16".
  8. Find the "Screen settings" box, this is where we configure our "hypothetical" LCD display. In actuality, this is the data that is send through the USB port to the gauges.
  9. Make sure the "Screen:" indicator reads "1" and the "Enabled" box is checked.
  10. On the first line type "$CPUUsage%B", this will 'display' CPU use followed by the letter "B". On the next line type "$MemU%A", this will 'display' memory use followed by the letter "A". The actual order of A and B is unimportant.
  11. Make sure all but the first screen are disabled by un-checking the "Enabled" box.
  12. Click 'OK' and LCD Smartie should show a representation of the display on your monitor.
If everything is configured correctly, the gauges should being showing CPU and memory use.

USB analog gauge - LCD Smartie(click thumbnails to view gallery)

LCD Smartie main screenLCD Smartie active screen

Taking it further

This project shows how an earlier design can quickly become another device. It doesn't stop here, we can carry on with additional features and design improvements:
  • A potentiometer would make it easy to tune the resistance connected to a gauge.
  • Six additional gauge drivers can be added.
  • The pins on port B are brought to a header. These can connect to buttons for data input.
Have fun, and be safe.

New to electronics? Here are some introductory tutorials to help you get started.

Eagle CAD tutorials
Draw Circuits with Eagle
Turn your Eagle Schematic into a PCB
Eagle Design Rules
Create a Custom Parts Library

Make circuit boards
Toner Transfer
Professionally, online

Soldering Tutorials
How to Solder
Sparkfun Soldering Basics

Microchip's PIC microcontroller
Microchip Website
Microchip USB Framework Source
PIC In-Circuit Serial Programming
The original JDM2 Programmer
Business Card PIC Programmer
Multi-Socket PIC Programmer
USB PIC Programmer

  • Mike Schramm

    That's incredibly awesome. Amazing job.

  • Superprime

    Why do this with surface mount parts? Everything there can be substituted for a part with DIP package

  • ian

    Last week I did a very similar design that was all through-hole. It's here:

    I did this design in SMD so the circuit board would fit inside my PC case.

    PS: I also like SMD because it saves all the time I used to spend drilling holes.

  • Chris Beach

    "After the fold"

    Is it just me or is the author of this article trying to originate another annoying catchphrase for blog articles?

  • Alistair

    I see that Ian got these gauges from some dollar-store bin. Does anyone have a line on where you could purchase gauges like these? I looked around but couldn't find too many amongst the diving and pressure gauges that litter the 'net.

  • HE3r0

    try automotive store and "voltage" gauges, they have a wide selection of these and it should work, though if you want to wire up an automotive tachometer that would show computer`s speed, it would not work.

  • Mark Tlay

    I think it would be a lot less work to use a sound card and a little amplifier (if needed) to drive the display. You can get old sound cards for about $5.

  • ka1axy73


    For sources of good quality surplus stuff, try these:
    "Hamfests" are a good bet -
    Fair Radio

    And they're actually called "meters". Gaugest are mechanical, used for pressure, etc.

  • MachineHead

    Ian, instead of the crystal + caps, you should look into resonators, they are 'all in one' devices. I've used them in all my PIC boards. check sparkfun for examples of their use.

    I agree that surface mount is the way to go. I used to be all about through-hole, but so many awesome devices don't have a DIP version (but DO have SOIC). Also, drilling 28 (or more) holes for an IC gets old, especially if one goes through as many board revisions as I do. (or simply the number of projects). All my boards now have USB + the 18F2550 at the 'core'. After a tiny bit of practice, soldering SMD gets easy.

    Also, take note about how he grounded his copper pour. I've made boards without that, and they don't work, it acts as a big capacitive plate, so your chip resets when you get near it. rather frustrating.

  • sspencer

    How about a capacitor across the gauge to slow down / smooth out the voltage changes for a more analog feel?

  • Matthew

    I'm not particularly experienced in electronics (more's the pitty) but am determined to use this design. I don't understand, though, how one can add more gauges.

    If that could be explained, to whatever level of detail might be felt necessary, I would appreciate it.

  • XErTuX

    Hello Ian.

    Thanks for your projects first.

    I will build this gauge project to my computer soon, i have the materials already.
    But i want to do USB Colour Changer too, but i dont need it's usb support, Auto-Fader is just enough for me. Could you update your program?
    We already have 4 free pins to use. It would be good if you make PortB.0 PortB1 and Portb2 Led connections, and PortB.3 to Open/Close RGB Led Function with a switch.

    I will build this PCB still. I can make another little board to drive transistors and Leds with 4 cable from PortB header pins.

    Please let me know fast and dont forget to attach your updated hex file if you success to do.

    All the best.

  • Michael Gray ( has a way of using an audio output as a source to drive analogue meters but as simple as it looks I could not get it to work. Has anyone tried it that way?


    Timberland Boots
    ghd hair straightners
    Mens Timberland 6 Inch
    Womens Timberland high cut

  • ws

    Timberland women's 6inch

  • Peter

    Is there any sourcecode for this project? I am keen to 'tinker' with the code. All I can find in the project zip is a hex file. Thanks

  • 16 Comments / 1 Pages

Add Your Comments

  • New Users
  • Returning

If you are posting a comment for the first time, please enter your name and email address in the fields above. Your name will be displayed with your comment. Your email address will never be displayed.

Add Your Comment

Please keep your comments relevant to this blog entry. Email addresses are never displayed, but they are required to confirm your comments.

When you enter your name and email address, you'll be sent a link to confirm your comment, and a password. To leave another comment, just use that password.

To create a live link, simply type the URL (including http://) or email address and we will make it a live link for you. You can put up to 3 URLs in your comments. Line breaks and paragraphs are automatically converted — no need to use <p> or <br /> tags.


Follow Us

  • No features currently available.

  • More Hot Topics The Daily Fix  •  DIY Warrior  •  Home Ec  •  Handmade
    DIY Disaster Doctor  •  In the Workshop  •  Product Picks

    Home Improvement Videos