Skip to main content

Computer Controlled Motor

This  project is the beginning of Arduino Robotics. Here we control the direction of motor by pressing defined key from keyboard.


Component Required

  1. Arduino.
  2. Motor. 
  3. Motor driver.
  4. computer.
  5. Jumper wires. 

Project Objectives

  1. To understand about the direction of Motor.

Circuit Diagram


Fig:- Circuit Diagram


- Connect Motor to the Motor driver as Shown in figure.
- Connect the Controller to pin from Motor driver to 6 & 7 pin of Arduino
- Connect 5V pin of Motor Driver to 5V pin of Arduino  and GND pin of Arduino To GND pin of Motor Driver.
Here the Function of Motor Driver is to drive the motor according to the instruction  given by the user.

CODE


int lm1=6;
int lm2=7;
void setup()
 {
  // put your setup code here, to run once:
  pinMode(lm1,OUTPUT);
  pinMode(lm2,OUTPUT);
  Serial.begin(9600);
  Serial.println("press \n forward 8 \n backward 2 \n stop others pin");

}

void loop()
 {
// put your main code here, to run repeatedly:
if(Serial.available());
{
int val= Serial.read();
Serial.print(val);
if(val==8)
{
  digitalWrite(lm1,HIGH);
  digitalWrite(lm2,LOW);
  Serial.println(" \n now moving forward");
}
else if(val==2)
{
  digitalWrite(lm1,LOW);
  digitalWrite(lm2,HIGH);
  Serial.println(" \n now moving backward");
}
else
{
  digitalWrite(lm1,LOW);
  digitalWrite(lm2,LOW);
  Serial.println(" \n now stop");
}
}
}
Now Upload the Code to the Arduino.
Then if you press 8 :- Motor will Rotates in ClockWise Direction 
         if you press 2:- Motor will Rotates in Anti-Clock wise Direction.
Except these two key if we press any key Motor will stop.


Popular posts from this blog

SMPS of computer

                                            fig:- working principle of SMPS       fig :- SMPS of computer From the above figure, we came to know that the function of SMPS in computer which is to convert  the high 220V-AC to 0-12V DC.SMPS contain several color of wires which carry the different voltage to the different parts of the computer.The following table shows the different color cables and its carrying voltage.      

warm clothes distribution program

‘ Small step can make a big difference ’ Rural Women Development Centre from morang,Nepal distributed the warm clothes to the needy people. They manage it possible by collecting fund from working staffs and management committe. Here is the video link of the distribution program. https://youtu.be/AxaHbivcQUM

Multiple mcp23017 interfacing with Arduino

MCP23017 is the I/O port extender that runs on 12C. It is 16-bit I/O expender.in this tutorial we are going to interface the single and multiple  mcp23017 with arduino.  fig:- mcp32017 module IT has 16 I/O ports from PA0 to PA7 and PB0 to PB7. first of all we are going to interface the single mcp23017 with Arduino. For this  connect the circuit as shown on figure. Download the library for mcp23017  from  sketch-- include library -- manage libraries.