Electronic Project 15: Manually operated circuit isolation using Optocoupler and Arduino uno
What Will I Learn?
At the end of this tutorial:
♦ The readers will be able to create a circuit isolation using the optocoupler and arduino uno.
♦ The readers will be able to know how optocoupler works.
♦ Learn to apply the circuit in other electronic projects with a high voltage.
Introduction
What is an optocoupler?
An Optocoupler, sometimes called Opto-isolator, Photocoupler & Optical-isolator, is an electronic component that transfers electrical signal between two isolated circuits by using light.
You can read more here
Requirements
Electronic Components
♦ Arduino Uno
♦ Optocoupler
♦ Resistor
♦ Battery
♦ DC Motor
♦ Pushbutton
♦ Breadboard
♦ Connecting wires
Software
♦ Fritzing application
Difficulty
♦ Advance
Tutorial Contents
Using the fritzing software, we will create our circuit diagram, arduino codes and prototype using the breadboard
Part I. Schematic Diagram
So first let us construct our circuit diagram.
Open the fritzing software and click on schematic.
Select the electronic components needed for the circuit in the fritzing library. We need 1 arduino uno, 1 optocoupler, 3 resistors, 1 battery and 1 pushbutton.
Arrange the components before constructing the circuit.
In arranging the components, place all the components for the input side (left side) of the arduino and the components for the output side (right side).
In this tutorial the input components will be the pushbutton and a resistor. The rest of the components are for the output side.
Now let us construct our circuit diagram. The input of our circuit will be the pushbutton in which it is connected to the 5V terminal and to analog pin 2 of our microcontroller.
At the output of our microcontroller, we will use the digital pin 13 as the output signal. This output is then connected to the resistor.
Then the resistor will be connected to the input side of our optocoupler component. As you know, the input component of an optocoupler or opto-isolator is a light source or the light emitting diode.
Then the output side of the optocoupler is a phototransistor which is to be connected to the load motor and a source battery.
So here is our final circuit diagram.
The pushbutton must be in off state first. Then the moment you will press the pushbutton it will be in on state and therefore current will conduct through the analog input pin 2.
The microcontroller will perform the programmed codes, that it will give an output in pin 13 the moment the pushbutton activates or in on state. There will be an output current through the resistor pin.
This output is then fed to the emitting diode input of the optocoupler. The light emitting diode will now trigger and it will produce light or infrared through the internal circuitry or package of the optocoupler. This emitting diode can convert electrical energy into light energy or photons.
The infrared light that being produce inside the package will be detected by the phototransistor.
Then the phototransistor will either generates electric energy directly or modulates electric current from external source. So here, the phototransistor will just modulates electric current from the source battery.
Now current will flow allowing the motor to operate.
Part II. Code
Now let us do programming of our Arduino uno.
Click on code to start.
For our arduino codes, our input component will be the pushbutton that is connected to analog pin 2. So we declare pin 2 as our input pin. And for the output pin will be the pin where the resistor is connected. So here, output pin 13.
int pushPin= 2;
int resistorPin = 13;
Since our aim is to manually operate the circuit using the pushbutton, so we will declare that the pushbutton state is “Off state”.
int pushState = 0; //it is the variable for reading the pushbutton status
void setup() {
// initialize the resistor pin as an output:
pinMode(resistorPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(pushPin, INPUT);
}
void loop(){
// read the state of the pushbutton value:
pushState = digitalRead(pushPin);
// check if the pushbutton is pressed.
// if it is, the pushState is HIGH:
if (pushState == HIGH) {
// give output on resistor pin
digitalWrite(resistorPin, HIGH);
}
else {
// no output at resistor pin
digitalWrite(resistorPin, LOW);
}
}
Here are the arduino codes.
int pushPin= 2;
int resistorPin = 13;
int pushState = 0;
void setup() {
pinMode(resistorPin, OUTPUT);
pinMode(pushPin, INPUT);
}
void loop(){
pushState = digitalRead(pushPin);
if (pushState == HIGH) {
digitalWrite(resistorPin, HIGH);
}
else {
digitalWrite(resistorPin, LOW);
}
}
Part III. Breadboard
Click on the breadboard.
Arrange each component in the breadboard before connecting.
Now connect each component if you don’t know how to connect using breadboard just read my previous tutorial about how to construct a circuit in the breadboard
Application
The readers can apply this tutorial in making isolation of circuit using optocoupler like this below.
link source
Curriculum
Here are my other tutorials for electronic projects.
ELECTRONIC PROJECTS
Tutorial 1
Tutorial 2
Tutorial 3
Tutorial 4
Tutorial 5
Tutorial 6
Tutorial 7
Tutorial 8
Tutorial 9
Tutorial 10
Tutorial 11
Tutorial 12
Tutorial 13
Posted on Utopian.io - Rewarding Open Source Contributors
Thank you for the contribution. It has been approved.
Can you improve your post format in your future tutorials please? Adding two spaces below images make them look better. I doesn't seem to have any other issue, so approved.
You can contact us on Discord.
[utopian-moderator]
I will @sakibarifin ..thank you for the suggestion..it really looks better.
Hey nice tutorial.
Just a reminder. If you implement this in the real world you have to look out for the spezifications of the optocoppler or it might get burned.
To be even more save you could trigger e relais with the optocoppler.
thanks @hawk399 ..a relay could be used also..thanks for that..
Good read. But i'm also the guy that puts everything into BTC hoping to get rich.
Very complicated for me to understand but wish you good luck
thanks @mrjames ..if you have time..try to read my previous tutorials so that you will learn the basics
Hey @rfece143 I am @utopian-io. I have just upvoted you!
Achievements
Suggestions
Get Noticed!
Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!
Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x