I have a hall effect sensor which outputs 0V when on the North pole of a magnet, 5V when on the South pole. It idles at 2.5V.

I want to connect 2 LEDs to show the reading, one activated from 0-2.5V, the other from 2.5V to 5V.

I could use the ADC on a microcontroller to read the sensor then drive the LEDs with two PWM channels. But, this seems like overkill to me.

Can anyone suggest a better way? Without using a microcontroller?


3 Answers 3


Simplest but probably worst method:

Connect the LEDs back-to-back, connect one leg to your signal voltage, and connect the other leg through a few kΩ resistor to a fixed 2.5 V source. Then one LED will be on from 0 V to 0.5 V, off from 0.5 V to 4.5 V, and the other LED on from 4.5 V to 5 V. Actual voltages would be determined by the color of the LED, and I think the brightness would only vary a little.

You could probably get exactly what you want with some kind of combination of the ideas of precision rectifier (using feedback for turn-on with no dead zone) and voltage-to-current converter (brightness proportional to voltage), but I'm having trouble thinking up a circuit.


If you want to do this with just a single LED you could just use a simple comparitor to generate a PWM signal to power the LED. Connect the positive lead of the comparitor to the output of your hall effect sensor and the other lead to a RC triangle wave generator.

For a good example of this type of circuit see http://www.solarbotics.net/library/circuits/bot_ornament_qlf.html. Just replace the connection to the lower frequency oscillator to your hall effect IC and you will have a PWM LED fader with 0 digital electronics!

  • \$\begingroup\$ Sounds like it could be done with a 555 timer also \$\endgroup\$ Mar 19, 2010 at 0:14

Maybe one of those tiny 6 or 8 pin SMD microcontrollers that are like a quarter inch square.

That wouldn't really be overkill, it might be $1, but to do it from standalone components you'd probably need quite a few different pieces. The main issue is that the way to vary LED brightness is via PWM, so you'd need some kind of oscillator that you could vary the frequency based on input voltage. Then use the output of the oscillator to drive the base of a transistor which is driving the LED.

For example this uber tiny microcontroller:


  • 512 Bytes of In-System Programmable Flash
  • 32 Bytes Internal SRAM.
  • One 16-bit Timer/Counter with PWM channels
  • 8-bit ADC
  • Analog Comparator.
  • Up to 12 MIPS throughput at 12 MHz.
  • 1.8 - 5.5 V operation.
  • Max I/O Pins: 4
  • Package: SOT23 6
  • Dimensions: 1.6mm x 2.9mm, thickness: 1.1mm
  • \$\begingroup\$ That's really quite awesome. \$\endgroup\$ Mar 18, 2010 at 22:51
  • 3
    \$\begingroup\$ The ATtiny5 isn't available anywhere. The similar PIC10 chips are widely available. \$\endgroup\$ Mar 18, 2010 at 23:26
  • \$\begingroup\$ Maybe it's too new...the ATtiny10 seems to be in stock at a few places. It's the same size, and mostly same features, just appears to have a bit more memory. \$\endgroup\$
    – davr
    Mar 19, 2010 at 14:37
  • 1
    \$\begingroup\$ $1.05 for one, or $0.66 each if you buy 25: search.digikey.com/scripts/DkSearch/… \$\endgroup\$
    – davr
    Mar 19, 2010 at 14:45
  • \$\begingroup\$ @Joby - I thought you didn't want a microcontroller? \$\endgroup\$
    – stevenvh
    Jun 12, 2011 at 13:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.