Home > Blog > Arduino 4 Channel Relay using ATmega328P with Proteus Simulation

Arduino 4 Channel Relay using ATmega328P with Proteus Simulation

Summary of Arduino 4 Channel Relay using ATmega328P with Proteus Simulation


This project shows an ATmega328P Arduino controlling four 12V relays via a ULN2003 driver, using simple two-digit serial commands to select relay (0–3) and state (1=ON, 0=OFF). Designed and tested in Proteus, it demonstrates firmware, driver electronics, and simulation for safe relay interfacing and automation.

Parts used in the Arduino 4 Channel Relay project:

  • ATmega328P (Arduino board)
  • ULN2003 relay driver IC
  • 4 × 12V relays
  • Resistors
  • Indicator LEDs
  • External 12V supply for relay coils
  • Serial terminal (Proteus virtual terminal)

Introduction

This Arduino 4 Channel Relay project demonstrates how an ATmega328P-based Arduino can control multiple high-power devices using a relay interface.
The system uses a ULN2003 driver IC to safely switch four 12V relays from low-voltage digital pins.
Designed and tested using Proteus simulation, this project is ideal for learning relay interfacing, serial control, and embedded systems automation.

It is a practical microcontroller project often used in DIY electronics and industrial control demos.
The setup shows how firmware, circuit design, and simulation work together in real-world applications.

Arduino relay Proteus schematic using ATmega328P

How the Project Works (Overview)

The Arduino listens for commands sent through the serial terminal.
Each command contains two digits:

  • First digit selects the relay number (0–3)

  • Second digit sets the relay state (1 = ON, 0 = OFF)

When a valid command is received, the Arduino drives the corresponding digital output pin.
These pins feed into a ULN2003 Darlington transistor array, which provides current amplification to energize the 12V relay coils.
The relay contacts then switch external loads safely, fully isolated from the microcontroller.

Block Diagram / Workflow Explanation

  1. Serial Terminal sends control command

  2. Arduino ATmega328P parses relay number and state

  3. Digital output pin goes HIGH or LOW

  4. ULN2003 driver amplifies current

  5. 12V relay switches ON or OFF

  6. Relay contacts control external devices

This workflow mirrors real industrial relay control systems and is accurately reproduced in Proteus.

Key Features

  • Controls 4 independent relays

  • Uses ULN2003 for safe current amplification

  • Serial-based relay control

  • Simple command format for testing

  • Fully compatible with Proteus simulation

  • Based on ATmega328P Arduino platform

  • Suitable for automation and switching projects

Components Used

  • ATmega328P (Arduino board)

  • ULN2003 relay driver IC

  • 4 × 12V relays

  • Resistors and indicator LEDs

  • External 12V supply for relay coils

  • Serial terminal (Proteus virtual terminal)

Applications

  • Home automation systems

  • Industrial relay control panels

  • Electrical appliance switching

  • IoT relay gateways (with expansion)

  • Learning relay interfacing in embedded systems

  • Laboratory automation projects

Explanation of Code (High-Level)

The firmware initializes four digital pins as outputs, each mapped to one relay.
Serial communication is configured at 9600 baud to receive user commands.

In the main loop:

  • The Arduino waits for serial input

  • Reads relay number and desired state

  • Validates the input

  • Sets the appropriate output pin HIGH or LOW

  • Sends status feedback back to the terminal

The ULN2003 handles relay coil current, allowing the Arduino to remain protected.

Arduino relay Proteus 4 channel relay module
Illustrative View of the Concept.

Source Code

Download

byte RelayPins[4] = {8,7,2,4};
char Input[1];

void setup() 
{
  for(int i = 0; i < 4; i++)  pinMode(RelayPins[i],OUTPUT);  // Set all Relay pins to output
  Serial.begin(9600); 
  delay(100); 
  Serial.println("4ChannelRelayShield demo sketch");
  Serial.println("Enter the RelayNumber and Mode");
  /* 
   *  RelayNumber - 0 to 3
   *  Mode - 1 for ON and 0 for OFF
   *  ex: To make Relay2 ON send 21 and to OFF send 20

Download Source Code

Proteus Simulation

In Proteus, the Arduino ATmega328P is connected to a ULN2003 driver and four relays.
A virtual terminal is used to send serial commands.
When commands are entered, the corresponding relay coil energizes, and relay contacts visibly switch.
This confirms correct firmware logic and hardware behavior before real-world deployment.

(FAQs)

[ultimate-faqs Include_category=”arduino-4-channel-relay”]

Conclusion

This Arduino 4 Channel Relay with Proteus Simulation project is a clean and practical example of relay interfacing in embedded systems.
It combines firmware logic, driver electronics, and simulation-based testing into one complete learning experience.
Perfect for beginners and intermediate developers, this project builds strong foundations for automation, industrial control, and DIY electronics applications.

Complete File

Arduino 4 Channel Relay using ATmega328P with Proteus Simulation

Download Complete File

Quick Solutions to Questions related to Arduino 4 Channel Relay project:

  • How does the project select which relay to switch?
    The first digit of the two-digit serial command selects the relay number (0–3).
  • How do you set a relay ON or OFF?
    The second digit of the two-digit serial command sets the relay state: 1 for ON and 0 for OFF.
  • Can the Arduino directly drive the 12V relay coils?
    No; the Arduino uses the ULN2003 driver IC to amplify current to safely energize the 12V relay coils.
  • What baud rate does the firmware use for serial communication?
    Serial communication is configured at 9600 baud.
  • How many relays does this project control?
    The project controls four independent relays.
  • What does the ULN2003 provide in this circuit?
    The ULN2003 provides Darlington transistor current amplification to drive the relay coils and protect the Arduino.
  • Is Proteus used in this project, and for what purpose?
    Yes; Proteus is used to simulate the Arduino, ULN2003, relays, and a virtual terminal to verify firmware and hardware behavior.
  • What are the example relay pin assignments in the code?
    The code maps relays to pins byte RelayPins[4] = {8,7,2,4}.
  • What feedback does the Arduino provide after receiving commands?
    The Arduino sends status feedback back to the terminal after setting the output pin.

About The Author

Muhammad Bilal

I am a highly skilled and motivated individual with a Master's degree in Computer Science. I have extensive experience in technical writing and a deep understanding of SEO practices.

Scroll to Top