1 Star 0 Fork 0

DFRobot/DFRobotRomeoBLEMini

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
DFRobotRomeoBLEMini.cpp 1.89 KB
一键复制 编辑 原始数据 按行查看 历史
jimaobian 提交于 2016-02-18 10:48 +08:00 . Init which meets the DFRobot code standard
/*!
* @file DFRobotRomeoBLEMini.h
* @brief DFRobot's Romeo BLE mini - Arduino with Motor Driver and Bluetooth 4.0 (SKU:DFR0351)
* @n CPP file for DFRobot's Romeo BLE mini
* @n [Schematics](https://raw.githubusercontent.com/CainZ/Romeo-BLE-mini/master/Romeo%20BLE%20mini%20V1.1%20Schematics%20.pdf)
*
* @copyright [DFRobot](http://www.dfrobot.com), 2016
* @copyright GNU Lesser General Public License
*
* @author [Angelo](Angelo.qiao@dfrobot.com)
* @version V1.0
* @date 2016-01-27
*/
#include "DFRobotRomeoBLEMini.h"
/*!
* @brief DFRobotRomeoBLEMini Constractor
*
* @param theReverseMA If set true, the direction of MA motor will be reverse.
* @param theReverseMB If set true, the direction of MB motor will be reverse.
* @param thePinMA1 MA1 pin number
* @param thePinMA2 MA2 pin number
* @param thePinMB1 MB1 pin number
* @param thePinMB2 MB2 pin number
*/
DFRobotRomeoBLEMini::DFRobotRomeoBLEMini(bool theReverseMA, bool theReverseMB, int thePinMA1, int thePinMA2, int thePinMB1, int thePinMB2)
{
reverseMA=theReverseMA;
reverseMB=theReverseMB;
pinMA1=thePinMA1;
pinMA2=thePinMA2;
pinMB1=thePinMB1;
pinMB2=thePinMB2;
}
/*!
* @brief set the speed and dirction of the motors, from -255 to 255.
*
* @param motorMA speed and dirction of motorMA
* @param motorMB speed and dirction of motorMB
*/
void DFRobotRomeoBLEMini::speed(int motorMA, int motorMB)
{
if (reverseMA) {
motorMA=-motorMA;
}
if (reverseMB) {
motorMB=-motorMB;
}
motorMA=constrain(motorMA, -255, 255);
motorMB=constrain(motorMB, -255, 255);
if (motorMA>0) {
analogWrite(pinMA1, motorMA);
digitalWrite(pinMA2, LOW);
}
else{
analogWrite(pinMA1, 255+motorMA);
digitalWrite(pinMA2, HIGH);
}
if (motorMB>0) {
analogWrite(pinMB1, motorMB);
digitalWrite(pinMB2, LOW);
}
else{
analogWrite(pinMB1, 255+motorMB);
digitalWrite(pinMB2, HIGH);
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/dfrobot/DFRobotRomeoBLEMini.git
git@gitee.com:dfrobot/DFRobotRomeoBLEMini.git
dfrobot
DFRobotRomeoBLEMini
DFRobotRomeoBLEMini
master

搜索帮助