DC Motor Control using XBee & Arduino in Proteus

Hello friends, I hope you all are doing great. In today's tutorial, we are gonna design a project named DC Motor Control using XBee & Arduino in Proteus ISIS. I have shared the complete code and have also explained it in detail. You can also download the complete working Proteus Simulation given at the end of this tutorial. In this project, I have designed two Proteus Simulations. The first Simulation is of Remote control in which I have used a keypad. The second simulation contains our two DC Motors and I am controlling the direction of those DC Motors with my Remote Control. XBee Module is used for sending wireless data. The code will also work on hardware as I have tested it myself. So, let's get started with DC Motor Control using XBee & Arduino in Proteus ISIS:

DC Motor Control using XBee & Arduino in Proteus

  • I have designed two Proteus Simulations for this project.
  • The First Simulation is named as Remote Control while the second one is named as DC Motor Control.
  • I am controlling the directions of these DC Motors from my Remote.
  • So, let's first have a look at Remote section and then we will discuss the DC Motor Control.
  • You can download both of these Proteus Simulations (explained below) and Arduino codes by clicking below button:
Download Proteus Simulation
Remote Control
  • Here's the overall circuit for Remote Control designed in Proteus ISIS:
  • As you can see in the above figure that we have Arduino UNO which is used as a microcontroller and then we have XBee module which is used for RF communication and finally we have Keypad for sending commands.
  • You have to download this XBee Library for Proteus in order to use this XBee module in Proteus.
  • You will also need to download Arduino Library for Proteus because Proteus doesn't have Arduino in it.
  • The Serial Monitor is used to have a look at all the commands.
  • Now next thing we need to do is, we need to write code for our Arduino UNO.
  • So, copy the below code and Get your Hex File from Arduino Software.
#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 4; //three columns
char keys[ROWS][COLS] = {
  {'7','8','9', '/'},
  {'4','5','6','x'},
  {'1','2','3','-'},
  {'*','0','#','+'}
};
byte rowPins[ROWS] = {13, 12, 11, 10}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {9, 8, 7, 6}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

int KeyCheck = 0;

void setup() 
{
  Serial.begin(9600);   

}

void loop() 
{
  char key = keypad.getKey();
  
  if (key)
  {
    if(key == '1'){KeyCheck = 1; Serial.print("1");}
    if(key == '2'){KeyCheck = 1; Serial.print("2");}
    if(key == '3'){KeyCheck = 1; Serial.print("3");}
    
    if(key == '4'){KeyCheck = 1; Serial.print("4");}
    if(key == '5'){KeyCheck = 1; Serial.print("5");}
    if(key == '6'){KeyCheck = 1; Serial.print("6");}

    if(KeyCheck == 0){Serial.print(key);}
    KeyCheck = 0; 
  }

}
  • The code is quite simple and doesn't need much explanation.
  • First of all, I have initiated my Keypad and then I have started my Serial Port which is connected with XBee Module.
  • In the Loop section, I am checking the key press and when any key is pressed our microcontroller sends a signal via XBee.
  • Now let's have a look at the DC Motor Control Section.
DC Motor Control
  • Here's the image of Proteus Simulation for DC Motor Control Section:
  • We have already installed the XBee & Arduino Library for Proteus in the previous section.
  • Here you need to install L298 Motor Driver Library for Proteus, which is not available in it.
  • So here we have used two DC Motors, which are controlled with L298 Motor Driver.
  • XBee is used to receive commands coming from Remote Control.
  • Now use below code and get your hex file from Arduino Software:
int Motor1 = 7;
int Motor2 = 6;
int Motor3 = 5;
int Motor4 = 4;

int DataCheck = 0;

void setup() 
{
  Serial.begin(9600);
  pinMode(Motor1, OUTPUT);
  pinMode(Motor2, OUTPUT);
  pinMode(Motor3, OUTPUT);
  pinMode(Motor4, OUTPUT);
   
  digitalWrite(Motor1, HIGH);
  digitalWrite(Motor2, HIGH);
  digitalWrite(Motor3, HIGH);
  digitalWrite(Motor4, HIGH);

  Serial.print("This Arduino Code & Proteus simulation is designed by:");
  Serial.println();
  Serial.println("        www.TheEngineeringProjects.com");
  Serial.println();
  Serial.println();
  Serial.println();
   
}

void loop() 
{
  if(Serial.available())
  {
    char data = Serial.read();
    Serial.print(data);
    Serial.print("      ======== >      ");
    
    if(data == '1'){DataCheck = 1; digitalWrite(Motor2, LOW);digitalWrite(Motor1, HIGH); Serial.println("First Motor is moving in Clockwise Direction.");}
    if(data == '2'){DataCheck = 1; digitalWrite(Motor1, LOW);digitalWrite(Motor2, HIGH); Serial.println("First Motor is moving in Anti-Clockwise Direction.");}
    if(data == '3'){DataCheck = 1; digitalWrite(Motor1, LOW);digitalWrite(Motor2,  LOW); Serial.println("First Motor is Stopped");} 

    if(data == '4'){DataCheck = 1; digitalWrite(Motor3, LOW);digitalWrite(Motor4, HIGH); Serial.println("Second Motor is moving in Clockwise Direction.");}
    if(data == '5'){DataCheck = 1; digitalWrite(Motor4, LOW);digitalWrite(Motor3, HIGH); Serial.println("Second Motor is moving in Anti-Clockwise Direction.");}
    if(data == '6'){DataCheck = 1; digitalWrite(Motor3, LOW);digitalWrite(Motor4,  LOW); Serial.println("Second Motor is Stopped.");}

    if(DataCheck == 0){Serial.println("Invalid Command. Please Try Again !!! ");}
    Serial.println();
    DataCheck = 0;
  }

}
  • In this code, I am receiving commands from my remote and then changing the direction of my DC Motors.
  • When it will get '1', it will move the first motor in Clockwise Direction.
  • When it will get '2', it will move the first motor in Anti-Clockwise Direction.
  • When it will get '3', it will stop the first motor.
  • When it will get '4', it will move the second motor in Anti-Clockwise Direction.
  • When it will get '5', it will move the second motor in Clockwise Direction.
  • When it will get '6', it will stop the second motor.
  • It will say Invalid Commands on all other commands.
  • Now let's have a look at its working & results.
Working & Results
  • Now run both of your Simulations and if everything goes fine, then you will have something as shown in below figure:
  • Now when you will press buttons from keypad then DC Motors will move accordingly.
  • Here's an image where I have shown all the commands.
So, that's all for today. I hope you have enjoyed today's project in which we have designed DC Motor Control using XBee & Arduino in Proteus ISIS. Thanks for reading !!! :)
Syed Zain Nasir

I am Syed Zain Nasir, the founder of <a href=https://www.TheEngineeringProjects.com/>The Engineering Projects</a> (TEP). I am a programmer since 2009 before that I just search things, make small projects and now I am sharing my knowledge through this platform.I also work as a freelancer and did many projects related to programming and electrical circuitry. <a href=https://plus.google.com/+SyedZainNasir/>My Google Profile+</a>

Share
Published by
Syed Zain Nasir