Using an optocoupler with a button

I want to use an optocoupler to isolate buttons and prevent crosstalk.

I have an 8 optocoupler board with 2 in/2 out terminal config.

I have wired one that works, but it needs resistors on both sides and I am not sure I did it right at all in terms of isolating circuitry.

How can I correctly use an optocoupler to isolate buttons and prevent crosstalk?

Thank you

Hello underhilll

Post your sketch, well formated, with well-tempered comments and in so called
code tags "< code >" and schematic to see how we can help.

Have a nice day and enjoy coding in C++.

Hi,
Welcome to the forum.

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

Please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.

Thanks.. Tom.. :grinning: :+1: :coffee: :australia:

An opto-coupler is simply a photo-diode on the input side and a phototransistor on the output. Assuming you are using 5V supply I would typically use 1K current limiting resistor on the input side and the port internal pullup on the output side, although 10K would not do any harm. It would interesting to know the application, as noise can often be overcome in software.

so something like this

Crosstalk is not normally a problem with buttons if there are bias resistors (or better the internal pullup resistors are active) and the connecting wires are not too long. Using an optocoupler here is an unusual solution to whatever the problem is in this case.

1 Like

Yes, provided the input supply and output supply are isolated with no common GND.

Thank you everyone for all of your comments, especially @J-M-L for the little schematic that helps a lot!

I have discovered, since my early experiments with buttons, that I can set multiple up on an analog pin so I am going to try that, at some point, I got distracted by the LCD and BME280 and TSL2561 part of the project :slight_smile:

Thanks again

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.