Relay is a switch to control devices which work on ac loads.Ac is alternative current which is used to power ac devices.
Project Description:
In this project we will be turning on a light bulb using realy and serial monitor and know how Relay work.
Steps:
Step 1:
Connecting 5v relay to Arduino
5V relay pin diagram consist of 7 pins we will only be using 3 of them which is:
Connections:
Step 2:
Connecting bulb to bulb holder and really
Connection:
What does no1 and nc1 and com1 actually mean?
Com1 which is short form of common1 is the center pole of the relay contacts.
No1 is normally open contact, it’s not in contact with common, and it makes contact with common when the relay is energized.
Nc1 is normally closed contact, it’s in contact with the common when the relay is not energized.
Step 3:
Copy and paste code from below in Arduino IDE
void setup()
{
Serial.begin(9600);
}
String rx_byte ;
void loop()
{
if (Serial.available() > 0) { // is a character available?
rx_byte = Serial.readString(); // get the character
if(rx_byte =="1")
{
digitalWrite(13,HIGH);
Serial.println("light on");
}
if(rx_byte =="0")
{
digitalWrite(13,LOW);
Serial.println("light off");
}
}
} // end: if (Serial.available() > 0)
Step 4:
Turning bulb on and off using serial monitor
Open serial monitor:
Input given:
The bulb will turn on when you give "1" as input in serial monitor and will turn off the light whenever it receives "0" as input.