“(SKU:ARD030301)L293D Shield直流马达驱动模块智能小车驱动”的版本间的差异

来自YwRobot Studio Wiki
跳转至: 导航搜索
(创建页面,内容为“L293D Shield直流马达驱动模块智能小车驱动 <br> ==产品参数...”)
 
 
(未显示另一用户的1个中间版本)
第26行: 第26行:
  
 
==使用教程==
 
==使用教程==
*[[File:L293D Shield直流马达驱动模块智能小车驱动LINE.jpg|500px|]]
+
*[[File:L293D Shield直流马达驱动模块智能小车驱动LINE.jpg|800px|]]
  
 
===样例代码===
 
===样例代码===
 
<pre style="color:blue">
 
<pre style="color:blue">
 +
//This motor shield use Pin 6,5,7,4 to control the motor
 +
// Simply connect your motors to M1+,M1-,M2+,M2-
 +
// Through serial monitor, type 'a','s', 'w','d','x' to control the motor
  
 +
int EN1 = 6;
 +
int EN2 = 5;  //Roboduino Motor shield uses Pin 9
 +
int IN1 = 7;
 +
int IN2 = 4; //Latest version use pin 4 instead of pin 8
 +
 +
void Motor1(int pwm, boolean reverse) {
 +
  analogWrite(EN1, pwm); //set pwm control, 0 for stop, and 255 for maximum speed
 +
  if (reverse) {
 +
    digitalWrite(IN1, HIGH);
 +
  }
 +
  else {
 +
    digitalWrite(IN1, LOW);
 +
  }
 +
}
 +
 +
void Motor2(int pwm, boolean reverse) {
 +
  analogWrite(EN2, pwm);
 +
  if (reverse) {
 +
    digitalWrite(IN2, HIGH);
 +
  }
 +
  else {
 +
    digitalWrite(IN2, LOW);
 +
  }
 +
}
 +
 +
void setup() {
 +
  int i;
 +
  for (i = 4; i <= 7; i++) //For Arduino Motor Shield
 +
    pinMode(i, OUTPUT);  //set pin 4,5,6,7 to output mode
 +
}
 +
 +
void loop() {
 +
  Motor1(255, true); //You can change the speed, such as Motor(50,true)
 +
  Motor2(255, true);
 +
  delay(500);
 +
  Motor1(255, false);
 +
  Motor2(255, false);
 +
  delay(500);
 +
  Motor1(150, false);
 +
  Motor2(150, true);
 +
  delay(500);
 +
  Motor1(150, true);
 +
  Motor2(150, false );
 +
  delay(500);
 +
}
 
</pre>
 
</pre>
 +
 +
==引脚分配图==
 +
{|border="1" cellspacing="0" align="center" cellpadding="5" width="600px"
 +
!style="background:#7dc2f5"|Pin
 +
!style="background:#7dc2f5"|Function
 +
|-
 +
|align="center"|Digital 4
 +
|align="center"|Motor 2 转向控制,高电平正转,低电平反转
 +
|-
 +
|align="center"|Digital 5
 +
|align="center"|Motor 2 PWM调速控制,范围0-255,0电机停转,255电机最大速度
 +
|-
 +
|align="center"|Digital 6
 +
|align="center"|Motor 1 PWM调速控制,范围0-255,0电机停转,255电机最大速度
 +
|-
 +
|align="center"|Digital 7
 +
|align="center"|Motor 1 转向控制,高电平正转,低电平反转
 +
|}
  
 
==更多==
 
==更多==

2017年1月9日 (一) 17:24的最新版本

L293D Shield直流马达驱动模块智能小车驱动



产品参数

  • 尺寸:62*55mm
  • 重量:16g
  • 逻辑电压:5V
  • 端口:数字
  • 驱动电压:7-12V
  • 驱动电流:1A(每路)
  • 平台:Arduino


产品特性

  • 全新原装正品L293D芯片
  • 双出输出,单路电流最大1A
  • 完全兼容Arduino UNO R3接口
  • 4IO控制两路马达转向、调速,节省IO
  • 板载LED状态指示灯,监控马达状态
  • 适用于驱动N20等直流马达
  • 可配合我店的MR2智能小车平台使用

使用教程

  • L293D Shield直流马达驱动模块智能小车驱动LINE.jpg

样例代码

//This motor shield use Pin 6,5,7,4 to control the motor
// Simply connect your motors to M1+,M1-,M2+,M2-
// Through serial monitor, type 'a','s', 'w','d','x' to control the motor

int EN1 = 6;
int EN2 = 5;  //Roboduino Motor shield uses Pin 9
int IN1 = 7;
int IN2 = 4; //Latest version use pin 4 instead of pin 8

void Motor1(int pwm, boolean reverse) {
  analogWrite(EN1, pwm); //set pwm control, 0 for stop, and 255 for maximum speed
  if (reverse) {
    digitalWrite(IN1, HIGH);
  }
  else {
    digitalWrite(IN1, LOW);
  }
}

void Motor2(int pwm, boolean reverse) {
  analogWrite(EN2, pwm);
  if (reverse) {
    digitalWrite(IN2, HIGH);
  }
  else {
    digitalWrite(IN2, LOW);
  }
}

void setup() {
  int i;
  for (i = 4; i <= 7; i++) //For Arduino Motor Shield
    pinMode(i, OUTPUT);  //set pin 4,5,6,7 to output mode
}

void loop() {
  Motor1(255, true); //You can change the speed, such as Motor(50,true)
  Motor2(255, true);
  delay(500);
  Motor1(255, false);
  Motor2(255, false);
  delay(500);
  Motor1(150, false);
  Motor2(150, true);
  delay(500);
  Motor1(150, true);
  Motor2(150, false );
  delay(500);
}

引脚分配图

Pin Function
Digital 4 Motor 2 转向控制,高电平正转,低电平反转
Digital 5 Motor 2 PWM调速控制,范围0-255,0电机停转,255电机最大速度
Digital 6 Motor 1 PWM调速控制,范围0-255,0电机停转,255电机最大速度
Digital 7 Motor 1 转向控制,高电平正转,低电平反转

更多

[YWRobot产品资料下载]

购买 YWRobot商城购买链接