Controlling 2 DC motors is the basic fundamentals of robotics because it tells the basic principles of the movements of a robotic car. Hello! Guys in this project we will be going through a step-by-step process on how to control our 2 dc motors using Arduino serial monitor in proteus 8 professional. You can control this project in a hardware format using components like:
The connection will be as follows: >> Connect the transistor's Collector to GND >> Connect the transistor's Base to a 270ohm resistor and connect the resistor's end to DIGITALPIN3 on the Arduino >> Connect the transistor's Emitter to the diode's negative(where there is no line) >> Connect the end of the diode(negative where there is a line) to any of the D.C.motor's PIN >> Connect the Diode's positive to 5v >> Connect the D.C.motor's another PIN to the transistor's Emitter PIN. Another method will be by using Bluetooth as a means of communication.
However, in this project, we will be looking at the software aspect to check and troubleshoot our errors before implementing the hardware project. As an engineer, you should, first of all, build a prototype to minimize your cost, effort and increase accuracy and efficiency. All said and one, our project consists of three (3) software.
Arduino IDE (Serial Monitor). In the Arduino serial monitor, we will be executing instructions that the motors should perform, that is to go forward, right turn, sharp right turn, left turn, sharp left turn, stop, and backward. This information will be shown also on the serial monitor as it executes in proteus 8 professional
Proteus 8 Professional ( o connect our components) In the Proteus 8 professional, we o our connections and upload our code into the Arduino in proteus 8 professional from Arduino IDE. One of the most important components in this connection is the COMPIM, which will be connecting the arduino serial monitor and proteus 8 professional
Com0Com ( the Virtual serial port) The null-modem emulator is an open-source kernel-mode virtual serial port driver for Windows that is free and GPL-licensed. With the Null-modem emulator, you can create an infinite number of virtual COM port pairs and use any pair to connect one COM port-based application to another. Each COM port pair provides two COM ports. The output of one port is the input of the other, and vice versa. The null-modem emulator can be used to provide a serial interface in device emulators. In this case, one of the ports is used by the device emulation program, while the other is used by a Windows or DOS application that needs to communicate with the device via a COM port.
If you want to know to connect your Arduino with proteus you can check out HERE
First, you connect your components in proteus 8 professional and used COMPIM to connect the proteus 8 professional virtually with the Arduino serial port via com0com virtual serial port >> Make sure the COMPIM is in the having an appropriate com port as that of the com0com the same baud rate and virtual baud rate as that of the Arduino, in this project, the baud rate, and the virtual baud rate is 9600 >> Connect the virtual serial port (com0com) by extending the 2 virtual com ports appropriate for pairing. One for Arduino and the other for proteus 8 professional >> use the Arduino serial monitor to display the executed instructions and also input the instruction in the serial monitor.
/*  * created by Afronics, https://afronics1.blogspot.com  * Control 2 DC motors with proteus 8 professional via Aruino serial monitor  */  int motor1Pin1 = 3; // pin 2 on L293D IC int motor1Pin2 = 4; // pin 7 on L293D IC int enable1Pin = 6; // pin 1 on L293D IC int motor2Pin1 = 8; // pin 10 on L293D IC int motor2Pin2 = 9; // pin 15 on L293D IC int enable2Pin = 11; // pin 9 on L293D IC int state; int flag=0;    //makes sure that the serial only prints once the state int stateStop=0; void setup() {     // sets the pins as outputs:     pinMode(motor1Pin1, OUTPUT);     pinMode(motor1Pin2, OUTPUT);     pinMode(enable1Pin, OUTPUT);     pinMode(motor2Pin1, OUTPUT);     pinMode(motor2Pin2, OUTPUT);     pinMode(enable2Pin, OUTPUT);     // sets enable1Pin and enable2Pin high so that motor can turn on:     digitalWrite(enable1Pin, HIGH);     digitalWrite(enable2Pin, HIGH);     // initialize serial communication at 9600 bits per second:     Serial.begin(9600); }  void loop() {     //if some date is sent, reads it and saves in state     if(Serial.available() > 0){           state = Serial.read();         flag=0;     }       // if the state is 'F' the DC motor will go forward     if (state == 'F') {         digitalWrite(motor1Pin1, HIGH);         digitalWrite(motor1Pin2, LOW);         digitalWrite(motor2Pin1, HIGH);         digitalWrite(motor2Pin2, LOW);         if(flag == 0){           Serial.println("Go Forward!");           flag=1;         }      }       // if the state is 'R' the DC motor will go RIGHT     if (state == 'R') {         digitalWrite(motor1Pin1, HIGH);         digitalWrite(motor1Pin2, LOW);         digitalWrite(motor2Pin1, LOW);         digitalWrite(motor2Pin2, LOW);         if(flag == 0){           Serial.println("RIGHT TURN!");           flag=1;         }     }        // if the state is '1' the DC motor will go SHARP RIGHT     if (state == '1') {         digitalWrite(motor1Pin1, HIGH);         digitalWrite(motor1Pin2, LOW);         digitalWrite(motor2Pin1, LOW);         digitalWrite(motor2Pin2, HIGH);         if(flag == 0){           Serial.println("SHARP RIGHT TURN!");           flag=1;         }     }          // if the state is 'L' the DC motor will go LEFT     if (state == 'L') {         digitalWrite(motor1Pin1, LOW);         digitalWrite(motor1Pin2, LOW);         digitalWrite(motor2Pin1, HIGH);         digitalWrite(motor2Pin2, LOW);         if(flag == 0){           Serial.println("LEFT TURN!");           flag=1;         }     }        // if the state is '2' the DC motor will go SHARP LEFT     if (state == '2') {         digitalWrite(motor1Pin1, LOW);         digitalWrite(motor1Pin2, HIGH);         digitalWrite(motor2Pin1, HIGH);         digitalWrite(motor2Pin2, LOW);         if(flag == 0){           Serial.println("SHARP LEFT TURN!");           flag=1;         }     }     // if the state is 'S' the motor will Stop     else if (state == 'S' || stateStop == 1) {         digitalWrite(motor1Pin1, LOW);         digitalWrite(motor1Pin2, LOW);         digitalWrite(motor2Pin1, LOW);         digitalWrite(motor2Pin2, LOW);         if(flag == 0){           Serial.println("STOP!");           flag=1;         }         stateStop=0;     }        // if the state is 'B' the motor will Reverse     else if (state == 'B') {         digitalWrite(motor1Pin1, LOW);         digitalWrite(motor1Pin2, HIGH);         digitalWrite(motor2Pin1, LOW);         digitalWrite(motor2Pin2, HIGH);         if(flag == 0){           Serial.println("Reverse!");           flag=1;         }     }     //For debugging purpose     //Serial.println(state); }  |