So connect the 5v and the ground of the arduino with the 5v and the ground of the relay module.
Interface relay module with arduino.
Or when the resistance of a photoresistor drops below 400 ohms.
Arduino connection with relay module.
It will get power when s is high.
In this example we will connect the relay module with arduino in the normally open state.
A relay is an electrically operated switch that can be turned on or off letting the current go through or not and can be controlled with low voltages like the 5v provided by the arduino pins.
Arduino digital pin 10 module pin s arduino gnd module pin arduino 5v module pin ac part of the circuit.
2 relay module interfacing with arduino 2 relay module is an electronic device consists of two relays as its major components.
Controlling a relay module with the arduino is as simple as controlling any other output as we ll see later on.
Code for relay with arduino.
As mentioned earlier by interfacing arduino with 5v relay module we intend to operate an ac load like lamp.
When ldr senses light intensity above 500 than the connection between com and no pin is broked and the light turns off.
Light intensity below 500 then the relay module gets input from arduino through pin 9 and there is a connection between the com and no pin is established and turns on the light.
For the dc part of the circuit.
Working is simple we need to make the relay pin pin a0 high to make the relay module on and make the relay pin low to turn off the relay module the ac light will also turn on and off according to relay.
The connections for connecting the relay module with arduino are very simple.
Introducing the relay module.
The working of the above sketch is as when the ldr senses darkness i e.
A simple project in which arduino uno controls a 5v relay is explained here.
The further detail about 2 relay module interfacing with arduino will be given later in this tutorial.
A relay can be used to control high voltage electronic devices such as motors and as well as low voltage electronic devices such as a light.
Let us discuss the working of the project.
In this configuration the relay is always closed and remains closed until you send a signal from the arduino to the relay module to open the circuit.
A relay is basically a switch which is operated electrically by electromagnet.
On the ac side connect your feed to common middle contact and use no normally open to lamp.
A normally open configuration works the other way in which the relay is always open until you send a signal from the arduino to the relay module to close the circuit.
Relay module for arduino is one of the most powerful application for arduino as it can be used to control both a c and d c devices by simply controlling the relay by giving 5v.
We just programmed the arduino to make the relay pin a0 high and low with a delay of 1 second.
The arduino can be programmed to turn on the 4 channel relay module when a certain event occurs for example when the temperature of a thermistor gets higher than 30 c.