Google "opto coupler " or "opto isolator" with the word arduino in front of it and the word "circuit" after it.
Have fun.
All you need is one resistor on the input side . I" ll let you see if you can figure out what to do with the
output side.
Henceforth ALL (or at least 99.99%) of your Google searches will contain the following KEYWORDS:
ARDUINO [blank] CIRCUIT CODE EXAMPLE
Where | [blank] is replaced with the device or subject of interest
In this case , your search is for opto isolators (AKA OPTOCOUPLERS),
thus , the search KEY PHRASE is:
"ARDUINO opto isolator CIRCUIT CODE EXAMPLE " (without the "")
Henceforth you will NOT post a new topic on the forum until you have:
1- done a GOOGLE SEARCH
2- done a search for any calculations or formulas that might be relevant to your topic
3- done a search for example code that might be relevant to your topic
4- drawn a schematic of your circuit.
5- If you don't know what it would look like do a Google search for "blank" SCHEMATIC
6- Made a list of relevant questions to ask in your post
7- composed a project SUMMARY/INTRODUCTION
8- compiled a list of LINKS (for the hardware you are interfacing) , copy and pasted into a Notepad file
and saved under the topic name
To Post a LINK;
- Click on the "chain" symbol between the computer monitor symbol and the envelope.
- Paste the URL (link) into the FIRST box you are promted with, click OK.
- Type in a label for the link (ie: "these", "here" , or the name of the thing, click OK.
9- compose your post in Notepad and reread it several times to look for omissions/mistakes
10- Learn how to read/use datasheets. Always post link to them when asking questions about the
thing/ic/device in question. Google the parameter names if you don't know what they mean.
(this is the 0.01% where you DON'T use the prefix "arduino" and the suffix "circuit")
Did I miss anything (ANYBODY .? ...ANYBODY ....?)
And learn how to draw a schematic so you can post a photo of your schematics.
Google schematic tutorial or something. That is VERY IMPORTANT. If you do NOT learn how to draw a
schematic , you will essentially be an electronics cripple. You will have a handicap that will always slow
you down and make it next to impossible to communicate with the forum members who reply to your
post. Make that your TOP priority.
FYI,
There is a special HELL reserved for people who don't read datasheets. It is a place where nothing
works and everything smokes when you turn the power on. I can't count the number of posts we've
seen on the forum because people didn't read the datasheets.
Also, you might want to read the specs for the arduino UNO on the home page to familiarize yourself
with the voltage limitations etc.
Also, you should do the examples that come with the IDE. When you click Tools, there should be an
Examples menu that allows you to select examples.
Good luck