Sign up ×
Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It's 100% free, no registration required.

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

share|improve this question
    
What relay board are you using? Do you hear the relay clicking? – Gerben Aug 6 at 13:29
    
yes I can here the relay clicking.! – Shiva N Aug 6 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 Aug 6 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. – Shiva N Aug 7 at 4:51
    
There are two transistors there (the small black things with are sort-of a semicircle). Please read the part number and post that. – Nick Gammon Aug 7 at 4:53

1 Answer 1

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,

Gil

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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