(SKU:ARD030300)L298P Shield直流马达驱动
来自YwRobot Studio Wiki
产品参数
- 尺寸:65*55mm
- 重量:25g
- 逻辑电压:5V
- 端口:数字
- 驱动方式:双路H桥
- 驱动电压:7-12V (7-18V单独供电)
- 驱动电流:<2A
- 平台:Arduino
产品特性
- 全新原装正品L298P芯片
- 双出输出,电流最大2A
- 高速肖特续流基二极管,性能稳定
- 4IO控制两路马达转向、调速,节省IO
- 管脚完全兼容Arduino UNO R3
- 适用于智能机器人小车的电机驱动
- 可配合我店的MR2智能小车平台使用
使用教程
样例代码
//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产品资料下载]