Introduction
In this article on IoT, I'll show you how to control Relay using the Galileo board. The Relay is basically an electrically controlled mechanical switch. Inside the Relay there is a plastic box that acts as an electromagnet when its energy causes a switch to trip.
Requirements:
- Galileo
- Bread Board
- Led
- Relay
- Some Wires
- Diode
- NPN Transistor
- Resistor
Connections:
Relay:
- Relay to digtial Pin 5
- Relay Gnd to Gnd
Led
- Anode pin to the 13
- Cathode pin to the Gnd
Programming
- const int Relay=5;
- int led=13;
- void setup()
- {
- pinMode(Relay,OUTPUT);
- pinMode(led,OUTPUT);
- }
- void loop()
- {
- if(led == 13){
- digitalWrite(Relay,HIGH);
- digitalWrite(led,HIGH);
- delay(100);
- }
- else{
- digitalWrite(Relay,LOW);
- digitalWrite(led,LOW);
- delay(100);
- }
- }
Explanation:
The Relay will act like an on and off switch, for that we sketch the program here. Make relay as const value in digital pin 5 and led as 13th pin in setup function. Set the pinMode for led and Relay and in the loop function, we want to give the condition for relay and how it wants to work; it takes the condition from the led pin.
- if(led == 13){
- digitalWrite(Relay,HIGH); // Relay ON
- digitalWrite(led,HIGH); // LED ON
- delay(100);
- } >
The above condition is true, which means the Relay is ON and Led also ON, or else the condition is false which means both will be in the off condition.
Output:

Read more articles on Internet of Things:


Delpin Susai RajTOP 100Posted Aug 28, 2016, 12:40 AM EDT
Nice one
Amit Kumar SinghPosted Feb 16, 2016, 10:40 PM EST
Good one sir
Santhakumar MunuswamyPosted Feb 16, 2016, 10:05 AM EST
Thanks for nice work
Raja TPosted Feb 14, 2016, 10:04 PM EST
Nice,Thanks for sharing
Sibeesh VenuTOP 100Posted Feb 14, 2016, 7:36 PM EST
Nice Share
Shubham KumarPosted Feb 14, 2016, 7:32 PM EST
nice one
Mohammed IbrahimPosted Feb 14, 2016, 6:25 PM EST
nice
Kumaresh RajalingamPosted Feb 13, 2016, 6:58 AM EST
Thanks Gowtham sir
Gowtham KTOP 100Posted Feb 13, 2016, 6:39 AM EST
Good One
Kumaresh RajalingamPosted Feb 13, 2016, 5:16 AM EST
Thanks SR
Sr KarthigaPosted Feb 13, 2016, 3:10 AM EST
Good one