Keegan Hu
/
finalwarehouse
ddd
Fork of whouse by
main.cpp
- Committer:
- glintligo
- Date:
- 2018-05-11
- Revision:
- 3:09f6061e6e5d
- Parent:
- 2:ecf401a37aa3
- Child:
- 4:d66b6f331b74
File content as of revision 3:09f6061e6e5d:
#include "mbed.h" #include "Stepper_motor.h" #include "robo.h" Serial Info(PB_10,PB_11); Ticker t1; void serial_ticker();//蓝牙串口中断函数 // puma black /*Stepper_motor s1(PB_9,PB_0,PB_7,PA_11,10,16,1); Stepper_motor s2(PB_6,PA_7,PB_4,PA_15,10,16,1); Stepper_motor s3(PB_3,PA_6,PA_12,PB_1,10,16,1); */ // en step dir button 减速比 细分数 初始方向 Stepper_motor s1(PA_6,PC_5,PC_4,PB_14,10,16,0);//x puma white Stepper_motor s2(PA_2,PA_5,PA_4,PC_6,10,16,1);//y Stepper_motor s3(PC_13,PC_3,PC_2,PB_15,10,16,0);//z //PwmOut pwm2(PA_1); //DigitalOut button(PA_0); float moterXdeg, moterYdeg, moterZdeg; int main() { {//初始化 Info.attach(&serial_ticker); s1.Init(); wait(5); s2.Init(); wait(5); s3.Init(); wait(5); } {//计算电机角度 moterXdeg = 1; moterYdeg = 2; moterZdeg = 3; //Info.printf("moterXdeg:%f moterYdeg:%f moterZdeg:%f\n",moterXdeg, moterYdeg,moterZdeg); } { //运动 /*若转动的角度为-1 则会一直转,此时rec_rate需大于0 * 除此之外,若转动角度或转速小于0,则电机反转 * 如在电机尚未停止前再次调用该函数,则会立刻开始新的电机运动 */ s1.Config(5,moterXdeg); //wait(5); //如果运动出现bug,可将上方注释去掉 s2.Config(5,moterYdeg); //wait(5); s3.Config(5,moterZdeg); //wait(5); } while(1) { } } void serial_ticker() { }