opto-coupler: transistor vs logic

NO

connect D9 between C1 and R2
R2 can have much higher resistans, 100 kohms.
0.1 uF and 100 kohms make an timeconstant (RC) of 10 ms

Pelle