The optocoupler is the most important part it isolates the circuit from the relay using.
Arduino transistor relay control.
A relay basically allows a relatively low voltage to easily control higher power circuits.
You can use a 5v relay to switch the 120 240v current and use the arduino to control the relay.
Below given is relay driver circuit to build your own relay module.
Learn how to use relay with arduino how relay works how to connect relay to arduino how to code for relay how to program arduino step by step.
If the transistor base terminal is 0 low then fan turns off for delay and other you can set with help of arduino ide and arduino uno.
Therefore we use the 5v supply voltage for the coil and use a npn transistor to turn on and off the low power electrical circuit.
The parts you will need.
2 x 220ω resistors.
1 x tip120 darlington transistor is recommended but any one that will handle your relay will work.
The picture above shows the circuit you need to build.
The detail instruction code wiring diagram video tutorial line by line code explanation are provided to help you quickly get started with arduino.
In this example when a pushbutton connected to digital pin 2 is pressed the arduino will control a transistor via pulse width modulation pwm which will ramp up the motor s speed then slow it back down.
The basic transistor switching with arduino for arduino digital 7th pin is output if the arduino send logic 1 high the mini cooling fan turns on.
The base of the transistor is connected to digital pin 9 of the arduino through a 1 kilohm resistor.
An ac bulb is used for demonstration.
When the button is pressed the fan will turn on and will remain in this state until the button is pressed again.
The second leg connected to analog in 0 of the arduino.
Circuit diagram and working.
In this arduino relay control circuit we have used arduino to control the relay via a bc547 transistor.
1 x 1n4001 diode.
A relay accomplishes this by using the 5v outputted from an arduino pin to energize the electromagnet which in turn closes an internal physical switch to.
The third leg is connected to ground.
In this quick arduino tutorial i will explain how you can control a relay using the arduino board one 1k and one 10k resistors 1 bc547 transistor one 6v or 12v relay one 1n4007 diode and a 12v fan.
First leg of the potentiometer is connected to 5 volts.
The arduino can only provide 40ma at 5v on its digital pins.
1 x sharp pc817 optocoupler.
We have connected transistor base to arduino pin a0 through a 1k resistor.
The following circuit shows how to control a relay with your arduino or esp8266 microcontroller.