The explanation of the schematic and function of the relay circuit is given in this video. A relay can be used instead of using a transistor depending on your component availability, budget, and electrical voltage/current ratings/needs.
For Your Information (FYI): You need to have a "pull-up" resistor of about 100K-ohm, at the secondary / input pin to establish the default "HIGH" value, which is not shown in this video. One lead of this "pull up" resistor should be connected to the +5V supply and the other lead connected to the input pin of the respective microcontroller. Either side of the 330-ohm resistor should work, but better / preferably on the side between the 330-ohm resistor and the input pin.
Correction: At the start of the description of the operation of the schematic, I meant to say that once the output pin gives a "HIGH" signal, the coil will become a magnet, which will close the switch and cause a "LOW" signal to be received at the input pin. This more accurately describes the schematic in this video. I used a "pull-down" resistor of about 100K-ohm in a slightly different circuit configuration, so my actual circuit would be "HIGH" when the relay flipped the normally open switch. The default was "LOW". This was not explained in this video.
For Your Information (FYI): A one-to-one transformer or optoisolator / optocoupler can also be used to isolate circuits. As in this video's explanation, the relay was the best available option. Depending on the current limit needed at the particular device, a current limiting resistor may be required; therefore, the resistance of a particular coil may be all that is necessary to meet the specification requirements. Also, a diode or capacitor placed across the coil leads can help to protect your circuit. So, in my case, I already had two reed switch relays from my component storage, that were there since the early 2000s, so they were financially "free" to me. The speed response requirement for my robot did not need to be within milliseconds, but in the hundredth or above, up to half of a second response time. It was not intended for communication or amplification needs, but simply switching needs. There isn't any bouncing issue. The relay was a (perfect) practical use in my specific situation. But, if I had optoisolators/optocouplers, I would have used them, which I have done in the past. :)
Two similar relay circuits were used to isolate two output pins from one microcontroller to two input pins of another microcontroller of the mobile manipulator named JOHNN-E-B. This is an acronym for Joint Operation Human Needs Next Evolution Bot. Motto: "I'm JOHNN-E-B. Come create with me!"
Here's the link to the other video that I mentioned/referred to in this video: • JOHNN-E-B Using Odometer Values for D...
The following link shows a video with the description about a schematic of a relay circuit that is used to control a motor that is powered by a separate battery: • Light Orienting Device Actuator Circuit
A photo transistor is used in that circuit. This video is an episode of a three part series titled "Light Orienting Device". There is a demonstration video and a construction tips video that uses this circuit. Here are the respective links: • Light Orienting Device and • Light Orienting Device Mechanical Con...
For fun :) : A squirrel appears in the video a couple of times. Did you notice this? If not, can you find it?
Watch the previous videos in this series for previous construction progress. Future updates on constructing a real robot will follow. Please click on the subscribe and like buttons and leave comments. Share this video if you think that someone else may enjoy or benefit from this video. Thank you very much for your support.