* SPICE netlist
XU1 Vin Ut3 Ub 0 C LM339 ;pnba In+)In-)V+)V-)OUT
XU2 Vin Ut2 Ub 0 ULED2 LM339 ;pnba In+)In-)V+)V-)OUT
XU3 Vin Ut1 Ub 0 A LM339 ;pnba In+)In-)V+)V-)OUT
R5 Ub C 1k
R6 Ub ULED2 1k
R7 Ub A 1k
XU4 Uh ULED2 Ub 0 A LM339 ;pnba In+)In-)V+)V-)OUT
R1 Ub Ut3 9.7k
R2 Ut3 Ut2 10.4k
R3 Ut2 Ut1 10.2k
R4 Ut1 0 9.6k
V1 Vin 0
V2 Ub 0 5V
R8 Ub Uh 40k
R9 Uh 0 10k
D3 ULED1 0 LUW-W5AP
D4 ULED2 0 LUW-W5AP
D1 C ULED1 1N4148
D2 A ULED1 1N4148
.dc V1 0 6 0.2
.inc lib/LM339.LIB

* LTspice schematic (.asc)
Version 4
SHEET 1 1536 768
WIRE -256 -208 -256 -288
WIRE -144 -208 -256 -208
WIRE -112 -208 -144 -208
WIRE 48 -192 48 -224
WIRE 48 -192 -48 -192
WIRE 112 -192 48 -192
WIRE 352 -192 112 -192
WIRE 528 -192 416 -192
WIRE 672 -192 528 -192
WIRE 768 -192 672 -192
WIRE -400 -176 -464 -176
WIRE -288 -176 -400 -176
WIRE -112 -176 -288 -176
WIRE -576 -160 -576 -176
WIRE -576 -160 -720 -160
WIRE -720 -144 -720 -160
WIRE -576 -144 -576 -160
WIRE -464 -144 -464 -176
WIRE -80 -144 -80 -160
WIRE -256 -128 -256 -208
WIRE 528 -128 528 -192
WIRE -720 -48 -720 -64
WIRE -720 -48 -768 -48
WIRE -576 -48 -576 -64
WIRE -464 -48 -464 -64
WIRE -720 -32 -720 -48
WIRE -256 0 -256 -48
WIRE -144 0 -256 0
WIRE -112 0 -144 0
WIRE 48 16 48 -16
WIRE 48 16 -48 16
WIRE 176 16 48 16
WIRE 320 16 176 16
WIRE 672 16 320 16
WIRE 768 16 672 16
WIRE -288 32 -288 -176
WIRE -112 32 -288 32
WIRE -720 64 -720 48
WIRE -80 64 -80 48
WIRE -256 80 -256 0
WIRE 320 112 320 16
WIRE 336 112 320 112
WIRE 528 128 528 -64
WIRE 528 128 400 128
WIRE 336 144 320 144
WIRE 368 176 368 160
WIRE -256 208 -256 160
WIRE -144 208 -256 208
WIRE -112 208 -144 208
WIRE 48 224 48 192
WIRE 48 224 -48 224
WIRE 176 224 48 224
WIRE 528 224 528 128
WIRE 528 224 176 224
WIRE -288 240 -288 32
WIRE -112 240 -288 240
WIRE -80 272 -80 256
WIRE -256 288 -256 208
WIRE -256 384 -256 368
FLAG -80 -144 0
FLAG -80 -224 Ub
IOPIN 128 96 In
FLAG -80 64 0
FLAG -80 -16 Ub
IOPIN 128 304 In
FLAG -80 272 0
FLAG -80 192 Ub
IOPIN 128 512 In
FLAG 48 -304 Ub
IOPIN 256 16 In
FLAG 48 -96 Ub
IOPIN 256 224 In
FLAG 48 112 Ub
IOPIN 256 432 In
FLAG 368 176 0
FLAG 368 96 Ub
IOPIN 576 416 In
FLAG 320 144 Uh
IOPIN 528 464 In
FLAG -256 -368 Ub
IOPIN -48 -48 In
FLAG -256 384 0
FLAG -464 -48 0
FLAG -576 -48 0
FLAG -576 -176 Ub
IOPIN -368 144 Out
FLAG -400 -176 Vin
FLAG -720 64 0
FLAG -768 -48 Uh
IOPIN -560 272 Out
FLAG -144 208 Ut1
FLAG -144 0 Ut2
FLAG -144 -208 Ut3
FLAG 176 224 A
FLAG 176 16 B
FLAG 112 -192 C
FLAG 768 -128 0
FLAG 768 80 0
FLAG 672 -192 ULED1
FLAG 672 16 ULED2
SYMBOL Opamps\\opamp2 -80 -256 R0
SYMATTR InstName U1
SYMATTR Value LM339
SYMBOL Opamps\\opamp2 -80 -48 R0
SYMATTR InstName U2
SYMATTR Value LM339
SYMBOL Opamps\\opamp2 -80 160 R0
SYMATTR InstName U3
SYMATTR Value LM339
SYMBOL Misc\\EuropeanResistor 32 -320 R0
SYMATTR InstName R5
SYMATTR Value 1k
SYMBOL Misc\\EuropeanResistor 32 -112 R0
SYMATTR InstName R6
SYMATTR Value 1k
SYMBOL Misc\\EuropeanResistor 32 96 R0
SYMATTR InstName R7
SYMATTR Value 1k
SYMBOL Opamps\\opamp2 368 64 R0
SYMATTR InstName U4
SYMATTR Value LM339
SYMBOL Misc\\EuropeanResistor -272 -384 R0
SYMATTR InstName R1
SYMATTR Value 9.7k
SYMBOL Misc\\EuropeanResistor -272 -144 R0
SYMATTR InstName R2
SYMATTR Value 10.4k
SYMBOL Misc\\EuropeanResistor -272 64 R0
SYMATTR InstName R3
SYMATTR Value 10.2k
SYMBOL Misc\\EuropeanResistor -272 272 R0
SYMATTR InstName R4
SYMATTR Value 9.6k
SYMBOL voltage -464 -160 R0
SYMATTR InstName V1
SYMATTR Value ""
SYMBOL voltage -576 -160 R0
SYMATTR InstName V2
SYMATTR Value 5V
SYMBOL Misc\\EuropeanResistor -736 -160 R0
SYMATTR InstName R8
SYMATTR Value 40k
SYMBOL Misc\\EuropeanResistor -736 -48 R0
SYMATTR InstName R9
SYMATTR Value 10k
SYMBOL LED 752 -192 R0
SYMATTR Value LUW-W5AP
SYMATTR InstName D3
SYMATTR Description Diode
SYMATTR Type diode
SYMBOL LED 752 16 R0
SYMATTR Value LUW-W5AP
SYMATTR InstName D4
SYMATTR Description Diode
SYMATTR Type diode
SYMBOL diode 352 -176 R270
SYMATTR Value 1N4148
SYMATTR InstName D1
SYMBOL diode 544 -64 R180
SYMATTR Value 1N4148
SYMATTR InstName D2