Control a Bulb with 8 channel Relay Module

Hi,

I am particularly new to Arduino and i am making a new project which includes controlling a bulb with 8 Channel Relay Module on Relay PIN 3. The Program which i have written includes Blinking the LED bulb after a few seconds(Basic Stuff).

I have connected Relay Module PINs IN1,IN2,IN3,IN4,IN5,IN6,IN7,IN8 to Arduino DIGITAL PIN 1,2,3,4,5,6,7,8 and Relay Module PIN GND to Arduino POWER GND, Relay Module PIN VCC to Arduino POWER VCC.

(I am uploading a PICTURE for referernce).

Can anyone have suggestions on what i might be doing wrong?

Regards,

Hi,
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

You are using PIN1 to control a relay, this is a programming pin, so it may be causing what ever your problem is.

Tom.... :slight_smile:

You should not use pin 1 of the Uno because that pin is used for communications with the PC. Same for pin 0.


Are you trying to electrocute yourself, or burn your house down? Mains power is dangerous and a beginner should avoid using it. Why do you not have a fused plug on the end of that mains cable? In UK sockets, if a plug with an earth pin is not inserted, the live and neutral connections are protected by shutters.

Please upload your code and clear wiring diagram!
You can refer to Arduino - Relay tutorial

manish169:
Can anyone have suggestions on what I might be doing wrong?

Well, the most blatantly obvious is playing with the power mains in an incredibly foolhardy fashion!

That unfocused picture taken in semi-darkness doesn't give much information and you have not posted your code. Presuming this is a 5 V relay board and not a 12 V, the fact that there is an indicator light on does suggest that the relay has actuated and it may be that you have connected the light to the "NC" and "NO" contacts instead of "NO" and "C". Again that is hard to see as it appears only one of the terminals has been screwed down.

No, more careful inspection indicates that the LED is on the input side of the opto-coupler and you have apparently removed the link from "VCC" to "JD-VCC" so there is no power to the relay itself, therefore while the LED is on, the relay is not.

Put the link back from "VCC" to "JD-VCC" and connect your Vcc and GND to the 10 pin header. Note this will only work for two or three relays as you are using USB power. If you want to use all eight relays, you must (remove the link,) connect "JD-VCC" and "GND" to plus and minus of a 5 V supply capable of one Amp, connect the INs and VCC but not GND to the Arduino.

You have not shown code, but presumably realise the Arduino outputs must pull LOW to operate the relay.

//the relays connect to
int IN1 = 1;
int IN2 = 2;
int IN3 = 3;
int IN4 = 4;
int IN5 = 5;
int IN6 = 6;
int IN7 = 7;
int IN8 = 8;

#define ON   0
#define OFF  1
void setup() 
{
 relay_init();//initialize the relay
}

void loop() {

 relay_SetStatus(ON, OFF);//turn on RELAY_1 
 delay(2000);//delay 2s
 relay_SetStatus(OFF, ON);//turn on RELAY_2
 delay(2000);//delay 2s
 relay_SetStatus(OFF, ON);//turn on RELAY_3
 delay(2000);//delay 2s
 relay_SetStatus(OFF, ON);//turn on RELAY_4
 delay(2000);//delay 2s
 relay_SetStatus(OFF, ON);//turn on RELAY_5
 delay(2000);//delay 2s
 relay_SetStatus(OFF, ON);//turn on RELAY_6
 delay(2000);//delay 2s
 relay_SetStatus(OFF, ON);//turn on RELAY_7
 delay(2000);//delay 2s
 relay_SetStatus(OFF, ON);//turn on RELAY_8
 delay(2000);//delay 2s
}
void relay_init(void)//initialize the relay
{  
 //set all the relays OUTPUT
 pinMode(IN1, OUTPUT);
 pinMode(IN2, OUTPUT);
 pinMode(IN3, OUTPUT);
 pinMode(IN4, OUTPUT);
 pinMode(IN5, OUTPUT);
 pinMode(IN6, OUTPUT);
 pinMode(IN7, OUTPUT);
 pinMode(IN8, OUTPUT);
 

 relay_SetStatus(OFF,OFF);//turn off all the relay
}
//set the status of relays
void relay_SetStatus( unsigned char status_1,  unsigned char status_2)
{
 digitalWrite(IN1, status_1);
 digitalWrite(IN2, status_2);
 digitalWrite(IN3, status_1);
 digitalWrite(IN4, status_2);
 digitalWrite(IN5, status_1);
 digitalWrite(IN6, status_2);
 digitalWrite(IN7, status_1);
 digitalWrite(IN8, status_2);


}

TomGeorge:
Hi,
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

You are using PIN1 to control a relay, this is a programming pin, so it may be causing what ever your problem is.

Tom.... :slight_smile:

Here is the diagram of my project(Screenshot and Fritz file both (in zip file) )

connect_8_channel_relay.zip (501 KB)

The relay board has output status LEDs, so you only have to confirm the bulb operation once, after you've fully written and debugged the software. You should omit the high voltage stuff until you have a proper enclosure to put it in, so you don't electrocute someone.

Hi,
I think you ad better provide a circuit diagram, not a Fritzy.

Please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Have you changed your circuit and code so that you do not use Pin 1?

Thanks.. Tom... :slight_smile:

If you want to make temporary connections to mains use a Test Block

That mains wiring is dreadful - you haven’t even wired the bulb holder correctly .

I’d suggest you do something else , 0/10.

manish169:
Here is the diagram of my project(Screenshot and Fritz file both (in zip file) )

8-module-relay-module.PNG
We don't do "ZIP" files on the Internet. :astonished:

Your diagram confirms my later explanation of your mistake, :roll_eyes:

You do not connect things to pin 1 of the Arduino if you wish to ever use serial communications.

Do yourself a favor and go buy a repair plug. put the wires into that.
or, go to a second hand shop and buy an old lamp. cut off the wires and throw the lamp away.
preferably with a switch in the cord.

for the wires, you will find it much easier to see what is happening if your control wires are short and straight out of the Arudino. keep things close. the long wire runs make the picture hard to see.

as for the power.
one line goes from the power source direclty to the bulb. it does not go through the relay at all.
the other wire goes from the power source to the COMM or C connection of the relay.

the bulb wire goes to the NO or normally open connection.

very simple. when the relay changes state the power flows from teh power strip to the C connection, then internally through the relay to the NO connection.
from the NO to one side of the bulb.
then from the other side of the bulb back to the power strip.