Converting a variable voltage to s stepped voltage
So that the output voltage snaps to the closest whole number


The devil is in the detail and a basic comparator idea won't do this - it'll always snap to the threshold just exceeded. To be able to arbitrate between upper and lower levels is best done using a PIC (or equivalent micro) - use an analogue (ADC) input, get a 10 bit number (typically), round up or down to the nearest integer of the count of 5 and output a 1 on one of 5 digital lines. Weight the digital lines with resistors into a summing amplifier and this should work.

Of course there is also the LM3914 - it takes an analogue voltage of 0 to 5V and drives ten LEDs: -



If you group the LED outputs in pairs this can replace the PIC mentioned above. It works like this: -