Saturday 7 January 2017

WEEK 7

Date: 7/11/2016-13/11/2016
Title: Controlling AC light using arduino with relay module

In this  week, the research is based on systems that using relay for switch on or off the bulb.

A relay allows circuits to be switched by electrical equipment.

How relays work

Relays are switches that open and close circuits electromechanically or electronically. Relays control one electrical circuit by opening and closing contacts in another circuit. As relay diagrams show, when a relay contact is normally open (NO), there is an open contact when the relay is not energized. When a relay contact is Normally Closed (NC), there is a closed contact when the relay is not energized. In either case, applying electrical current to the contacts will change their state. 
Relays are generally used to switch smaller currents in a control circuit and do not usually control power consuming devices except for small motors and Solenoids that draw low amps. Nonetheless, relays can "control" larger voltages and amperes by having an amplifying effect because a small voltage applied to a relays coil can result in a large voltage being switched by the contacts. 
Protective relays can prevent equipment damage by detecting electrical abnormalities, including overcurrent, undercurrent, overloads and reverse currents. In addition, relays are also widely used to switch starting coils, heating elements, pilot lights and audible alarms. 
Circuit diagram relay 4 channel
Interface arduino with relay 
In this project, we will go to  interface arduino with relay. This is simple project. We just only use push button to control the relay. If i push the button, relay will switch on and bulb will be on. 

The component needed:
1. Arduino Uno
2. Push Button
3. Relay module  5V DC to AC 240V
4. The Bulb
5. Resistor 10Kohm (for push button).

The connection between relay and arduino

The code
const int buttonPin = 2;     // the number of the pushbutton pin

const int LIGHT =  13;      // the number of the LIGHT pin



// variables will change:

int buttonState = 0;         // variable for reading the pushbutton status


void setup() {

  // initialize the LED pin as an output:
  pinMode(LIGHT, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);
}



void loop() {

  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);



  // check if the pushbutton is pressed.

  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {
    // turn LED on:
    digitalWrite(LIGHT, HIGH);
  } else {
    // turn LIGHT off:
    digitalWrite(LIGHT, LOW);
  }
}


The result should be like that:





No comments:

Post a Comment