Can I use a PC817 optocoupler to act as a momentary switch?

I have a KVM (Keyboard/Video/Mouse) switch that connects two work monitors to a single PC. It came with a little (wired) remote that has a momentary button. There is a constant 5V to the button and when the button is pressed it closes the connection, which causes the KVM to toggle between the two monitors. I want to control this via my Arduino.

This is what I came up with. Is this correct? Can it be used this way? I could put a relay on there instead but I figured an optocoupler would suffice.

The theory then is that I set the GPIO to OUPTUT HIGH and when I want to break the connection (to switch the KVM) I just issue a quick LOW on that pin.

Thanks!

Most probably yes, except that the optocoupler should not try to short circuit the 5V power of the KVM, but only the button.

A HIGH on the pin will close the remote button.

1 Like

Thank you!

I will try this out.

I set everything up per the chart. For testing I am using a 9V fan connected to a battery.

When I switch the GPIO pin to HIGH I am seeing the opto open (when I put a multimeter on it) but the current does not seem to flow (fan wont power). Fan is connected as follows:

Opto Pin 4 > Fan +
Opto Pin 3 > Battery +
Fan - > Battery -

Any ideas why the opto is not passing through the current when open?

Hi,

  1. Will your fan run directly off the 9V battery?
  2. What are the specs of your fan?
  3. What are the specs of your PC817, what current is the output transistor rated at?
  1. When you put the DMM on WHAT????
  2. WHAT pins?

Please draw a schematic, include pin NUMBERS and your fan and battery.

Tom.... :smiley: :+1: :coffee: :australia:

1 Like

opto "on" were a better description.

Perhaps you already killed the transistor by too much current.

I got it working! I think it was the fan or battery that was the issue.

The only problem I have now is that the KVM was actually normal closed not open as I first thought, and it only switches when a quick connection is made. So for example, if I just touch the two wires together and hold them longer than a half second it won't switch, but if I quickly tap the wires then it switches. No matter what a try in the code, any or no delay between the HIGH and LOW doesn't work. Note: I did have my DMM on the opto pins 3&4 and could see the 5v on/off when the code ran so at least I know that's working.

Am I going about this the wrong way? Maybe I need a relay after all..

Thanks!

How that if the switch is normally closed?

That sounds extremely implausible. Perhaps you should try and explain what you mean?

No, you need to learn how to explain things. :grin:

You need to provide a diagram of what you are connecting.

You need to post - according to the forum guidelines - the code you are using to make each test.

Hi,

How do you come to that conclusion?
Please explain.

Tom... :smiley: :+1: :coffee: :australia: