Interfacing of Relay WITH ARDUINO using ULN2003

For interfacing of relay with arduino using ULN2003, we need ULN IC (it can also be done with transistor but ULN is better option) in between arduino & relay because relay can generate back EMF because of its coil and this back EMF can affect our arduino board, so to save our controller or development board side circuitry we will use ULN2003 IC as relay driver.

INTERFACING OF RELAY WITH ARDUINO USING ULN2003

DC LOAD (5V, 12V, 24V….)

Arduino ULN with DC LOAD
ULN with DC LOAD

AC LOAD (~ 220 V)

We can connect LED for low voltage or high voltage appliance like 110/220 V, 60/50 Hz AC using relay. For connecting AC appliance see the circuit diagram below and code remains the same.

Arduino ULN with AC LOAD
ULN with AC LOAD

As we know ULN IC are Darlington pair IC and have transistors on the chips, we know transistor have 3 terminals namely base, emitter, collector so the inputs are base ranges from 1B to 7B with grounded common emitter to all seven drivers and corresponding collectors as output for each base input. +12V to COM point is for flyback diode which protects circuitry from back EMF.

Programming Code

/* don't use keywords for variables that are predefined by the software Arduino IDE
    that’s why we are using ip instead input and op instead output
*/
#define del 20
int ip = 2, op = 13;

int buttonState = 0;
void setup() {
  pinMode(ip, INPUT);             //ip=2
  pinMode(op, OUTPUT);       //op=13
}

void loop() {
  /* reading the state of input either HIGH (button pressed) or LOW (button not pressed)
     if button pressed appliance will ON otherwise not
  */
  buttonState = digitalRead (ip) ;
  if (buttonState = = HIGH) {
    digitalWrite(op, HIGH) ;
    delay(del) ;
  }
  else if (buttonState = = LOW) {
    digitalWrite(op, LOW) ;
    delay(del) ;
  }
}

DESIGN LOGIC GATES USING TRANSISTOR

Leave a Reply

avatar
  Subscribe  
Notify of

Arduino Tutorials with Basic Electronics: CONTENT

Translate »