![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
1
Diff: move.cpp
- Revision:
- 0:c52fc2fdd2e0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/move.cpp Mon Jun 27 21:14:19 2016 +0000 @@ -0,0 +1,59 @@ +#include "mbed.h" +#include "move.h" +#include "mbed.h" +DigitalOut dir1(PA_10);//PA_10 + DigitalOut dir2(PB_3);//PB_3 + PwmOut speeds(PB_4); +DigitalOut dirr1(PA_9);//PA_8 +DigitalOut dirr2(PC_7);//PB_5 +PwmOut speeds2(PB_10); +DigitalOut relays(PA_8); + + + + void move:: movespeed_1(float setpoint,float spd) +{ + float dc=0; + if(setpoint>=0) + { + dir1=1; + dir2=0; + // printf("if1\n"); + } + else + { + dir1=0; + dir2=1; + // printf("else1\n"); + } + dc=setpoint+spd; + // printf("%f\n",dc); + speeds2.write(dc); + + +} +void move:: movespeed_2(float setpoint,float spd) +{ + double dc=0; + if(setpoint>=0) + { + dirr1=1; + dirr2=0; + // printf("if2\n"); + } + else + { + dirr1=0; + dirr2=1; + // printf("else2\n"); + } + dc=setpoint+spd; + // printf("%f\n",dc); + speeds.write(dc); + + +} +void move::pump(int on_off) +{ + relays=on_off; +} \ No newline at end of file