My aim is to switch an electric bulb operating at 220v AC. For this purpose I use a 12V DC relay that can operate for 220V appliance according to its data sheet. My relay circuit is as under:
Using a regulated power supply (a desktop PC's SMPS unit with 12v, 5v, and 3.3v outputs), when 5V is applied to the pin of microcontroller, I get a click sound from the relay and the bulb is switched ON and when the pin is kept open, the bulb is OFF.
But when using an Arduino Uno board for the same purpose (I have 12V, 5V, 3.3V and GND pins on the board so I give all of the supply from the board itself now not from the separate supply), when I connect 12V GND and 5V at the pin that goes to MCU pin the relay is making noise. I am getting a continuous clicking sound from the relay. If I connect the bulb to it, it may damage my bulb (I'm assuming this since the relay seems to be switching fast and continuously)
Why am I getting the noise of clicking continuously when I use Arduino instead of the power supply?
How could I solve this problem?