How to Control 220V Light Bulb from 5V Arduino using a Relay

In this tutorial, you will learn how to control a 220V light bulb from 5V Arduino using a relay.

Parts Required

  • Arduino
  • Relay
  • Jumper wires
  • Light Bulb
  • Breadboard

Circuit

Code

void setup() {
 pinMode(2, OUTPUT);
}

void loop() {
 digitalWrite(2, HIGH);
 delay(2000); 
 digitalWrite(2, LOW); 
 delay(2000);
}

The code shown will turn the light on and off at 2-second intervals, if you want to put a button to control it just add a digital input.

References

[1] https://forum.arduino.cc/t/arduino-hangs-when-connecting-220v-to-relay-board/609411

Leave a Reply

Your email address will not be published. Required fields are marked *

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!

Hello! We have noticed you are using an ad blocker. Our website is funded by advertising which allows you to access all our content for free. By disabling your ad blocker, you are contributing to the sustainability of our project and ensuring we continue to provide high-quality, useful tutorials. We appreciate your support!