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 RajPosted Aug 28, 2016, 4:40 AM
Nice one
Amit Kumar SinghPosted Feb 17, 2016, 3:40 AM
Good one sir
Santhakumar MunuswamyPosted Feb 16, 2016, 3:05 PM
Thanks for nice work
Raja TPosted Feb 15, 2016, 3:04 AM
Nice,Thanks for sharing
Sibeesh VenuPosted Feb 15, 2016, 12:36 AM
Nice Share
Shubham KumarPosted Feb 15, 2016, 12:32 AM
nice one
Mohammed IbrahimPosted Feb 14, 2016, 11:25 PM
nice
Kumaresh RajalingamPosted Feb 13, 2016, 11:58 AM
Thanks Gowtham sir
Gowtham KPosted Feb 13, 2016, 11:39 AM
Good One
Kumaresh RajalingamPosted Feb 13, 2016, 10:16 AM
Thanks SR
Sr KarthigaPosted Feb 13, 2016, 8:10 AM
Good one