I dont know why but whenever the relay is on, my lcd decreased the light so it's really hard to see the parameter in the lcd while relay is on. Can you guys help me? Btw sorry for my bad grammar
Nothing to do with your code.
Inadequate Power supply.
i use 5v 2A power supply (yeah it's phone charger) through the usb port (i use arduino nano), what power supply i should use?
What is this relay?
How is it powered?
Do you have the DC+ connected to the Arduino 5V pin?
Which Arduino are you using?
(yeah it's phone charger)
Is it actually a phone charger or a general purpose 5V 2A supply.
yes it's 5v 2A supply, I also connected the dc+ of relay to the Arduino Nano 5v pin
Post an annotated schematic showing exactly how you have wired it. Include all power sources and other hardware. Post links to the power supply you are using. It is a power supply problem. If you do not want to do the drawing get a different power supply and try again.
