0

I want to control AC bulb with Arduino, 5v-relay. My connections are

enter image description here

My code is

#define RELAY1  7

void setup() 
{
  pinMode(RELAY1, OUTPUT);
  Serial.begin(9600);
}

void loop() 
{
  digitalWrite(RELAY1,LOW); // Turns ON Relays 1
  Serial.println("Light OFF");
  delay(15000); // Wait 5 seconds
  digitalWrite(RELAY1,HIGH); // Turns Relay Off
  Serial.println("Light ON");
  delay(20000);
}
  • Red LED is on according to AC bulb.
  • Power LED (Green colored one) is also on as I have given 5v supply from Arduino.

The issues are

  1. Bulb is not following the delay given in the code. The output for the above code is 20sec ON - 15sec OFF -20sec ON - 15sec OFF- 20sec ON -15sec OFF - 1sec ON - 20sec ON - 15sec OFF etc. means apart from 20,15 sec duration there is a duration of 1sec is coming in between as noise. What might be the reason?

  2. On monitor also, only first 3 actions are getting printed after that no printing is observed.

==>The relay I am using is:

enter image description here

10
  • What relay board are you using? Do you hear the relay clicking?
    – Gerben
    Commented Aug 6, 2015 at 13:29
  • yes I can here the relay clicking.!
    – NShiva
    Commented Aug 6, 2015 at 17:23
  • As Gerben says, please state the relay part number, and give a link to it. Are you sure you connected Vcc on the relay to the +5 V pin on the Arduino?
    – Nick Gammon
    Commented Aug 6, 2015 at 21:46
  • @Nick, I dont have link to relay. But I have uploaded the relay picture in the question it self. I am sure that 5v pin on Arduino connected to 5v pin on the relay.
    – NShiva
    Commented Aug 7, 2015 at 4:51
  • 1
    There is nothing on the back of the board except the metal connections.
    – NShiva
    Commented Aug 7, 2015 at 6:33

2 Answers 2

1

what i would do is test the parts one by one. so first look if you're signal is good by attaching a led to it. then test you're relay with 5v.

now you should know what the problem is the arduino or the relay

0

Everything looks good, however Try a different relay, and double check your AC side and be sure the bulb voltage is correct for the AC and the bulb is OK.

You may have a power shortage from your USB or however you are powering it. If you can monitor the 5VDC and be sure it is stable.

Good Luck

Not the answer you're looking for? Browse other questions tagged or ask your own question.