• Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors
Previous Next

DC Motor Driver Breakout (L298 Chipset) on pcDuino

Posted by: , September 9, 2014

[vc_row][vc_column][vc_column_text]4[/vc_column_text][vc_tour][vc_tab title=”Product Description” tab_id=”1410318697-1-29″][vc_column_text]600px-DC_motor

Specification:

  1. chipset: L298N
  2. Driving power supply voltage Vs: +5V  to +46V
  3. Peak current of driving power supply Io: 2A
  4. Vss: +5V to +7V
  5. Current of logic power supply: 0 – 36mA
  6. PWM control signal range:
    1. Low level: -0.3V < Vin < 1.5V
    2. High level: 2.3V < Vin< Vss
  7. Enable signal range:
    1. Low level: -0.3V
    2. High level: 2.3V < Vin< Vss
  8. Maxium power consumption: 25W
  9. Working temperation: -25C to 130C

[/vc_column_text][/vc_tab][vc_tab title=”Hardware prepare” tab_id=”1410318697-2-62″][vc_column_text]

DC Motor Driver Breakout (L298 Chipset)P Motor shield 2

pcDuino3: A20 Single Board Computer supports Arduino Programming

pcDuino

Rover: WiFi Remote Control Robot with WiFi Video Camera

Motor car

[/vc_column_text][/vc_tab][vc_tab title=”Wire diagram” tab_id=”1410325419469-2-1″][vc_column_text]

3
pinI1 of Motor shield  - >       pin 8  on pcDuino
pinI2 of Motor shield  - >       pin 11 on pcDuino
speedpinA of Motor shield  - >   pin 12 on pcDuino
 pinI3 of Motor shield     - >    pin 9  on pcDuino
pinI4 of Motor shield  - >       pin 13    on pcDuino
speedpinB of Motor shield  - >   pin 10  on pcDuino                   

600px-DC_motor[/vc_column_text][/vc_tab][vc_tab title=”Test Code” tab_id=”1410325420469-3-8″][vc_column_text]

#include <core.h>
 
#define pinI1     8  //define IN1 interface
 
#define pinI2     11 //define IN2 interface 
 
#define speedpinA 9  //enable motor A
 
#define pinI3     12 //define IN3 interface 
 
#define pinI4     13 //define IN4 interface 
 
#define speedpinB 10 //enable motor B
 
#define spead     200 //define the spead of motor
 
void forward()
 
{
 
     analogWrite(speedpinA,spead);//input a simulation value to set the speed
 
     analogWrite(speedpinB,spead);
 
     digitalWrite(pinI4,HIGH);//turn DC Motor B move clockwise
 
     digitalWrite(pinI3,LOW);
 
     digitalWrite(pinI2,LOW);//turn DC Motor A move anticlockwise
 
     digitalWrite(pinI1,HIGH);
 
}
 
void backward()
 
{
 
     analogWrite(speedpinA,spead);//input a simulation value to set the speed
 
     analogWrite(speedpinB,spead);
 
     digitalWrite(pinI4,LOW);//turn DC Motor B move anticlockwise
 
     digitalWrite(pinI3,HIGH);
 
     digitalWrite(pinI2,HIGH);//turn DC Motor A move clockwise
 
     digitalWrite(pinI1,LOW);
 
}
 
void left()
 
{
 
     analogWrite(speedpinA,spead);//input a simulation value to set the speed
 
     analogWrite(speedpinB,spead);
 
     digitalWrite(pinI4,HIGH);//turn DC Motor B move clockwise
 
     digitalWrite(pinI3,LOW);
 
     digitalWrite(pinI2,HIGH);//turn DC Motor A move clockwise
 
     digitalWrite(pinI1,LOW);
 
}
 
void right()
 
{
 
     analogWrite(speedpinA,spead);//input a simulation value to set the speed
 
     analogWrite(speedpinB,spead);
 
     digitalWrite(pinI4,LOW);//turn DC Motor B move anticlockwise
 
     digitalWrite(pinI3,HIGH);
 
     digitalWrite(pinI2,LOW);//turn DC Motor A move clockwise
 
     digitalWrite(pinI1,HIGH);
 
}
 
void stop()
 
{
 
     digitalWrite(speedpinA,LOW);
 
   //Unenble the pin, to stop the motor. This should be done to avid damaging the motor. 
 
     digitalWrite(speedpinB,LOW);
 
     delay(2000);
 
}
 
void setup()
 
{
 
  pinMode(pinI1,OUTPUT);
 
  pinMode(pinI2,OUTPUT);
 
  pinMode(speedpinA,OUTPUT);
 
  pinMode(pinI3,OUTPUT);
 
  pinMode(pinI4,OUTPUT);
 
  pinMode(speedpinB,OUTPUT);
 
}
 
void loop()
 
{
 
  left();
 
  delay(2000);
 
  stop();
 
  right();
 
  delay(2000);
 
  stop();
 
  forward();
 
  delay(2000);
 
  stop();
 
  backward();
 
  delay(2000); 
 
  stop(); 
 
}

[/vc_column_text][/vc_tab][vc_tab title=”Run and result” tab_id=”1410327669643-4-2″][vc_column_text]

 

 

Input the code into Arduino IDE, then click compile and upload

You will see the led light and the car will move

3[/vc_column_text][/vc_tab][/vc_tour][/vc_column][/vc_row]

Share!
Tweet

About the author

Leave a Reply Cancel reply

You must be logged in to post a comment.

Category

  • Home
  • pcDuino
  • WiKi
  • Store
  • Distributors