(SKU:ARD030301)L293D Shield直流马达驱动模块智能小车驱动
来自YwRobot Studio Wiki
产品参数
- 尺寸:62*55mm
- 重量:16g
- 逻辑电压:5V
- 端口:数字
- 驱动电压:7-12V
- 驱动电流:1A(每路)
- 平台:Arduino
产品特性
- 全新原装正品L293D芯片
- 双出输出,单路电流最大1A
- 完全兼容Arduino UNO R3接口
- 4IO控制两路马达转向、调速,节省IO
- 板载LED状态指示灯,监控马达状态
- 适用于驱动N20等直流马达
- 可配合我店的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产品资料下载]