常量
const int a = 5;
控制舵机转动速度
原理是将一大步分为多个小步运动,并在每一步执行后delay一段时间。
所以需要知道初始角度fromPos,以及最终位置toPos。还需要考虑角度由小到大的运动和由大到小的运动。
if (fromPos <= toPos){ //如果“起始角度值”小于“目标角度值”
for (int i=fromPos; i<=toPos; i++){
base.write(i);
delay (15);
}
} else {
for (int i=fromPos; i>=toPos; i--){
base.write(i);
delay (15);
}
蓝牙模块
注意默认波特率
注意蓝牙模块高电平的值,是否需要外围电路