Arduino Relay Module 1

A relay can be used, for example, to control the power to a small home appliance. I used this Arduino 2-Channel Relay Module (AC 250V 10A / DC 30V 10A) to control multiple appliances by replacing the mechanical on/off switch of a regular power bar with this relay.

The control of the relay by an Arduino microcontroller is straight forward. Two Arduino digital output pins (I used pins 2 and 3) are connected to CH1 and CH2 pins on the module to supply the activation signals for relay channels 1 and 2, respectively. The power bar is controlled by CH1 signal.

 

The following code switches the power  to the appliances connected to the power bar every 30 seconds. I used an office lamp for testing.

/*
  Switches the relay on and off every 30 secs
*/

const int channel_1_Pin = 2; // 
const int channel_2_Pin = 3; // 
const int delayValue = 3000;  // 30 sec

void setup() {
  pinMode(channel_1_Pin, OUTPUT);
  pinMode(channel_2_Pin, OUTPUT);
  digitalWrite(channel_1_Pin, LOW);
  digitalWrite(channel_2_Pin, LOW);
  delay(1000);
}

void loop() {
  digitalWrite(channel_1_Pin, HIGH);
  digitalWrite(channel_2_Pin, LOW);
  delay(delayValue);
  digitalWrite(channel_1_Pin, LOW);
  digitalWrite(channel_2_Pin, HIGH);
  delay(delayValue);
}

One comment on “Arduino Relay Module

  1. Andrew Nov 30,2012 7:41 am

    Good post, i want to make all switches in home in web inteface + bluetooth remote control… this very cool and funny for people who want to make something realy cool in his home
    Thanks

Comments are closed.