Control AC Light Using Arduino

Control AC Light Using Arduino © CC BY-NC-SA

In this tutorial, I will show how to interface a 5V relay with Arduino and control an AC load.

  • 1,865 views
  • 1 comment
  • 12 respects

Components and supplies

Apps and online services

About this project

The first tutorial everyone suggests for Arduino is blinking anLED. Today, I will show you how to control an AC light/appliance with the same blink sketch.

Controlling an AC light or appliance with Arduino is as simple as blinking an LED using Arduino. All you need to is take proper care while doing this project because here we are dealing with AC current (230V is more than enough to kill you). So beware!

What Is a Relay?

Relays are switches that open and close circuits electromechanically. They control one electrical circuit by opening and closing contacts in another circuitA relay has 5 pins namely COIL A, B, NO, NC, COM

There are 5 Pins in a relay. Two pins A and B are two ends of a coil that is inside the relay. The coil gets energized whenever current passes through it.

NC = Normally Closed is connected to pin when the relay coil is not energized.

NO = Normally Open, is left disconnected when the relay coil is not magnetized and is connected COM when the relay coil is energized.to pin when the relay coil is not energized.

COM = Common, At no input state, the COM is connected to NC. When the operating voltage is applied to relay coil gets energized and the COM changes contact to NO

Why BC547?

5V relay needs about 200mA current at 5V. But the digital pins of Arduino provides only 20 mA current. So Arduino cannot drive the relay directly. So as amplifier we need to used a transistor to drive the relay

Why Diode?

The relay coil cannot change it’s current instantly, diode provides a path for the current when the coil is switched off. Otherwise, a voltage spike will occur causing arcing on switch contacts or possibly destroying switching transistors

Video

Let’s Start Building

The circuit is very simple and small, there is only few things to place.

Wire as per the below-given schematics

This is an illustration of the circuit

Upload Code to Arduino

There is no need to download any code you have the code within the software just upload the Blink Sketch and watch the AC light blinking as a LED blinks

This is just basic tutorial on interfacing relay with Arduino. This project can be improved to a higher level like home automation using a smartphone, clap switch, and much more

Subscribe to blog for newsletter and like my Facebook page for receiving new post notification.

Code

CodeArduino
Upload the code to your arduino
void setup() {
  pinMode(13, OUTPUT);    
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(13, HIGH);   
  delay(1000);                      // Wait for a second
  digitalWrite(13, LOW);  
  delay(2000);                   
}

Schematics

Schematic
Connect as per the given circuit diagram
Ac circuit schem rohfj3dhiv

Comments

Similar projects you might like

Servo Control with TV Remote Control

Project showcase by eldo85

  • 7,587 views
  • 5 comments
  • 23 respects

How to control your light switch from your smartphone?

Project in progress by Mahmoud Ahmed

  • 22,811 views
  • 3 comments
  • 15 respects

Blinds (Or Any AC Power Motor) Control

Project tutorial by gomecin

  • 13,002 views
  • 23 comments
  • 61 respects

Arduino Control AC Water Heater temperature

Project tutorial by Mohannad Rawashdeh

  • 9,510 views
  • 0 comments
  • 6 respects

WIZnet S2E Light Control

Project tutorial by Team S2ELighting

  • 1,448 views
  • 0 comments
  • 7 respects
Add projectSign up / Login