I’m doing an audio project using a couple of Arduino Pro Minis. Both are the 5-volt version. Arduino-1 will send Arduino-2 a signal using an optocoupler. Arduino-2 will control some text to speech audio components. To reduce the impact of noise on the audio side, I plan to use an optocoupler between Arduino-1 and Arduino-2.
The Broadcom/Avago HCPL-817-00AE is the specific optocoupler I’m considering (datasheet here).
I think a 220 Ohm resistor would be right for R1. I have some 1N4007 diodes for the extra diode.
What value of resistor would you recommend for R2?
If it is a digital signal and the 2 Arduinos operate at the same supply voltage you can just connect a digital output pin on Arduino 1 directly to a digital input pin on Arduino 2. Put a 1k or so resistor in series to offer some protection to the input pin. The grounds will need to be connected.
Please describe what you want to do and what you have to do it with.
You do not need - and are better off without - the pull-up on the second device given that the optocoupler is mounted directly adjacent to it, INPUT_PULLUP will be just fine.
If there is any distance between, opto-isolation will be beneficial to audio devices connected to the second device as it will prevent a possible ground loop.
You are transferring a digital signal, so there is no need to use an analog pin on the second device, but on the basic Arduinos "analog" pins are (with a couple of exceptions) actually additional functions to an actual digital pin.
My original plan was to have an Ethernet module (ENC28J60) connected to pins 10, 11, 12, 13 on an Arduino Pro Mini 5-volt. I was going to have a DFPlayer Mini connected on other pins.
Setting this combination up on a breadboard led to all sorts of problems with the DFPlayer. When it would play an audio track, it would often stop half-way through. Sometimes the track would not play at all even though the player was getting a signal (an LED lights up when a track is played). This problem persisted even when the connections were made with really solid breadboard wiring connections. Removing the ENC28J60 solved all of these problems.
In trying to troubleshoot this, I found that other people also had problems when combining an ENC28J60 and a DFPlayer Mini in the same project. The DFPlayer seems a bit sensitive.
Since I have an extra Arduino Pro Mini, I figured the easiest and surest solution would be to move the audio to another Arduino. The opto-isolator seemed like an extra guarantee that the DFPlayer wouldn’t have playback difficulties.