* SPICE netlist
XU1 N010 0 N006 N012 PC817 Igain=1m ;pnba A)K)C)E
D1 0 N010 D
V1 N009 0 PULSE(0 5 1 0 0 2 4 3)
V2 N006 0 5
R1 N010 N009 1k
XU2 N005 0 N003 0 PC817 Igain=1m ;pnba A)K)C)E
R3 N005 N004 22k
R4 N001 N003 20k
V3 N004 0 PULSE(0 12 1 0 0 2 4 3)
Q1 N007 N013 0 0 2N3055
R2 N013 N012 1kR
R5 N002 N007 1kR
R6 N008 0 10k
S1 N008 N002 N002 N007 MYSW
V4 N002 0 24
V5 N001 0 5
R7 N019 N018 22k
R8 N015 N017 20k
V6 N018 0 PULSE(0 12 1 0 0 2 4 3)
V7 N015 0 5
Q2 N017 N019 0 0 NPN
R9 N021 N020 200
V8 N020 0 PULSE(0 5 1 0 0 2 4 3)
V9 N016 0 12
Q3 N016 N021 N022 0 NPN
R10 N022 0 200
V10 N011 0 3.3
D2 N011 N014 D
D3 N003 N014 D
.tran 10

* LTspice schematic (.asc)
Version 4
SHEET 1 2176 1184
WIRE -416 -576 -576 -576
WIRE 1024 -544 816 -544
WIRE 1088 -544 1024 -544
WIRE -416 -480 -416 -576
WIRE -576 -464 -576 -496
WIRE -448 -400 -512 -400
WIRE -416 -400 -448 -400
WIRE -352 -400 -416 -400
WIRE -1024 -384 -1088 -384
WIRE -800 -384 -944 -384
WIRE -512 -384 -512 -400
WIRE -512 -384 -608 -384
WIRE -1088 -368 -1088 -384
WIRE -1088 -352 -1088 -368
WIRE 816 -336 816 -544
WIRE 912 -336 816 -336
WIRE 672 -304 576 -304
WIRE 816 -304 816 -336
WIRE 1024 -304 1024 -544
WIRE -800 -288 -848 -288
WIRE -528 -288 -608 -288
WIRE 912 -288 912 -336
WIRE 976 -288 912 -288
WIRE -1088 -256 -1088 -288
WIRE -848 -256 -848 -288
WIRE -528 -256 -528 -288
WIRE -448 -192 -448 -400
WIRE 576 -192 576 -224
WIRE 816 -192 816 -224
WIRE 976 -192 976 -240
WIRE 976 -192 816 -192
WIRE 1024 -192 1024 -224
WIRE 176 -144 128 -144
WIRE 304 -144 256 -144
WIRE 400 -144 304 -144
WIRE 400 -128 400 -144
WIRE 416 -128 400 -128
WIRE 672 -128 672 -304
WIRE 672 -128 608 -128
WIRE 128 -112 128 -144
WIRE 304 -112 304 -144
WIRE 816 -80 816 -192
WIRE 1024 -80 1024 -112
WIRE -688 -32 -800 -32
WIRE 304 -32 304 -48
WIRE 416 -32 304 -32
WIRE 640 -32 608 -32
WIRE 752 -32 720 -32
WIRE 768 -32 752 -32
WIRE -688 0 -688 -32
WIRE -592 0 -688 0
WIRE -448 0 -448 -128
WIRE -448 0 -528 0
WIRE 128 48 128 -32
WIRE 304 48 304 -32
WIRE -800 64 -800 48
WIRE -128 80 -288 80
WIRE 816 80 816 16
WIRE -128 176 -128 80
WIRE 736 176 576 176
WIRE -288 192 -288 160
WIRE -128 256 -224 256
WIRE -64 256 -128 256
WIRE -736 272 -800 272
WIRE -432 272 -656 272
WIRE -224 272 -224 256
WIRE -224 272 -320 272
WIRE -800 288 -800 272
WIRE 576 288 576 256
WIRE -800 304 -800 288
WIRE -432 320 -432 272
WIRE -384 320 -432 320
WIRE 736 352 736 176
WIRE 736 352 640 352
WIRE -240 368 -320 368
WIRE 128 368 64 368
WIRE 432 368 208 368
WIRE 640 368 640 352
WIRE 640 368 544 368
WIRE 64 384 64 368
WIRE -800 400 -800 368
WIRE -240 400 -240 368
WIRE 64 400 64 384
WIRE 432 416 432 368
WIRE 480 416 432 416
WIRE 624 464 544 464
WIRE 624 480 624 464
WIRE 736 480 624 480
WIRE 64 496 64 464
WIRE 624 496 624 480
WIRE 736 592 736 560
FLAG 128 48 0
FLAG 576 -192 0
FLAG 304 48 0
FLAG -528 -256 0
FLAG -1088 -256 0
FLAG 816 80 0
FLAG 1024 -80 0
FLAG 1088 -464 0
FLAG -848 -256 0
FLAG -576 -464 0
FLAG -240 400 0
FLAG -800 400 0
FLAG -288 192 0
FLAG 64 496 0
FLAG 576 288 0
FLAG 736 592 0
FLAG -800 64 0
SYMBOL Optos\\PC817A 512 -80 R0
SYMATTR InstName U1
SYMBOL diode 320 -48 R180
SYMATTR InstName D1
SYMBOL voltage 128 -128 R0
SYMATTR InstName V1
SYMATTR Value PULSE(0 5 1 0 0 2 4 3)
SYMBOL voltage 576 -320 R0
SYMATTR InstName V2
SYMATTR Value 5
SYMBOL res 272 -160 R90
SYMATTR InstName R1
SYMATTR Value 1k
SYMBOL Optos\\PC817A -704 -336 R0
SYMATTR InstName U2
SYMBOL res -928 -400 R90
SYMATTR InstName R3
SYMATTR Value 22k
SYMBOL res -432 -496 R0
SYMATTR InstName R4
SYMATTR Value 20k
SYMBOL voltage -1088 -384 R0
SYMATTR InstName V3
SYMATTR Value PULSE(0 12 1 0 0 2 4 3)
SYMBOL npn 752 -80 R0
SYMATTR InstName Q1
SYMATTR Value 2N3055
SYMBOL res 736 -48 R90
SYMATTR InstName R2
SYMATTR Value 1kR
SYMBOL res 800 -320 R0
SYMATTR InstName R5
SYMATTR Value 1kR
SYMBOL res 1008 -208 R0
SYMATTR InstName R6
SYMATTR Value 10k
SYMBOL sw 1024 -208 M180
SYMATTR InstName S1
SYMATTR Value MYSW
SYMBOL Misc\\battery 1088 -560 R0
SYMATTR InstName V4
SYMATTR Value 24
SYMBOL voltage -576 -592 R0
SYMATTR InstName V5
SYMATTR Value 5
SYMBOL res -640 256 R90
SYMATTR InstName R7
SYMATTR Value 22k
SYMBOL res -144 160 R0
SYMATTR InstName R8
SYMATTR Value 20k
SYMBOL voltage -800 272 R0
SYMATTR InstName V6
SYMATTR Value PULSE(0 12 1 0 0 2 4 3)
SYMBOL voltage -288 64 R0
SYMATTR InstName V7
SYMATTR Value 5
SYMBOL npn -384 272 R0
SYMATTR InstName Q2
SYMBOL res 224 352 R90
SYMATTR InstName R9
SYMATTR Value 200
SYMBOL voltage 64 368 R0
SYMATTR InstName V8
SYMATTR Value PULSE(0 5 1 0 0 2 4 3)
SYMBOL voltage 576 160 R0
SYMATTR InstName V9
SYMATTR Value 12
SYMBOL npn 480 368 R0
SYMATTR InstName Q3
SYMBOL res 720 464 R0
SYMATTR InstName R10
SYMATTR Value 200
SYMBOL voltage -800 -48 R0
SYMATTR InstName V10
SYMATTR Value 3.3
SYMBOL diode -592 16 R270
SYMATTR InstName D2
SYMBOL diode -464 -192 R0
SYMATTR InstName D3