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!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
100% Free SEO Tools - Tool Kits PRO