For this Tutorial we are going to make an external power source for arduino.
Those are the components we need:
-1 Arduino Uno
-1 Breadboard
-1 Led
-1 Resistance
-1 Diode
-1 Relay ——–SRD-05VDC-SL-C
-1 9V Battery or 6 * 1.5V batteries
In this project we have a new component called Diode, which is used for controlling the flux of energy that runs on the circuit.
The schematic symbol is:

This symbol is easy to understand, it’s a sideways triangle with a barrier at the end. In this symbol we can conclude that the energy flow goes from the part of the triangle opposite to the barrier. If you try to send energy through the end with the barrier to the other and test it, you will see that it is impossible to pass energy that way.
The diode is really important here, because it prevents energy passage directly from the arduino uno to the breadboard. What should happen is the energy passing from the batteries, to the arduino, then to the relay and finally to the breadboard.
So now that we know a little bit more about diodes, we can start our project with the external power source. This process is represented in the sketch below:


As you can see we have a scheme with 2 electric power sources in parallel, which means if the main power source for arduino fails we have the batteries to maintain the circuit running.
Our code is just activating the relay with :
digitalWrite(rele,HIGH);
The purpose of using this diode is to make the energy flow like this:
batteries->arduino->Relay->circuit
or
Arduino power source->Relay->circuit
The circuit now has 2 power sources in parallel that work together to try to make the system always on.
This serves to show that the light continues ON even after you remove the cable from your computer.
When the relay is ON, the led remains ON. When it’s OFF, the led remains the same.
This was another tutorial made for you to understand better “electronics” with arduino.
Alexandre Leitao
Gonçalo Neto