I want to switch on/off some device using a 4n35 opto-isolator and Arduino but I have some questions.
I need a "manual" way to turn on/off the device without the control of Arduino.
Can I use the base of the transistor like the schematic?
Is there a better way?
The connection to D4 is to tell arduino that the system is in Auto/Manual mode
Connecting like that really removes your isolation.
Also, you say D4 but I think you mean D5 tells you the auto/manual mode.
A better way, and to keep your isolation, is to add a switch disconnecting D4 from the 4N35 pin 1 when you want to manual, and use a switch to connect pin1 to +5 via 150 ohm resistor when you want it on, and connect the Run/stop switch so it grounds on the isolated side when you want it stopped indepemdently of the arduino or the manual switch.
That would work also.
When Man/Auto is closed and Run/Stop is open, the Arduino is in control.
If Run/Stop happens to be closed at the same time, the arduino won't sink more than ~35mA if it should try & take the output Low.
When Man/Auto is open, Run/Stop close & open acts the same as Arduino High/Low.
Probably get more consistent results (current flow thru the LED) if th 4N35 pin 2 goes to ground, and you move the 220 ohm resistor between D4 and the Man/Autoswitch.
Just to be on the really safe side, I would put a high value resistor in parallel with the LEDs, better yet on the transistor's base. It makes me chill to see totally undriven electronic "inputs"...