Amber Tang
/
testLimitSwitch_Lifting_20170819
123
Revision 0:3c119cb9fc49, committed 2017-09-20
- Comitter:
- Amber77
- Date:
- Wed Sep 20 20:36:02 2017 +0000
- Commit message:
- 20170921
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 3c119cb9fc49 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Sep 20 20:36:02 2017 +0000 @@ -0,0 +1,123 @@ +/* https://developer.mbed.org/users/andrewrussell/code/Servo/ */ +/* JS using 3.3V */ +#include "mbed.h" + + +DigitalOut LiftingStopRun(PA_15); +DigitalOut F_R(PA_14); // CW/CCW +DigitalOut H_F(PA_13); + +DigitalIn LimitSwitchUp(PB_15,PullUp); +DigitalIn LimitSwitchDown(PB_14,PullUp); +//DigitalIn TIM(D6); + +DigitalOut myled(LED1); +DigitalIn mybutton(USER_BUTTON); +int control_mybutton=0; +int Control_LiftingStopRun=1; +int Control_F_R=1; + +int main() +{ + int limitSwitchUp; + int limitSwitchDown; + + + + H_F.write(1); + while(1) + { + limitSwitchUp = LimitSwitchUp.read(); + limitSwitchDown = LimitSwitchDown.read(); + //if (mybutton == 1) +// { +// printf("Amber01 \n"); +// } +// if (mybutton == 0) +// { +// if(control_mybutton == 0) +// { +// printf("Amber02\n"); +// } +// else if(control_mybutton == 1) +// { +// printf("Amber03\n"); +// } +// control_mybutton = 1-control_mybutton; +// printf("%d \n",control_mybutton); +// wait(0.2); + //if (mybutton == 1) +// { +// Control_LiftingStopRun=1; +// Control_F_R=1; +// +// LiftingStopRun.write(Control_LiftingStopRun); // 0:Run 1:Stop +// F_R.write(Control_F_R); // 0:turn down 1:turn up +// printf("Amber01\n"); +// } + if (mybutton == 0) + { + Control_LiftingStopRun=0; + LiftingStopRun.write(Control_LiftingStopRun); // 0:Run 1:Stop + F_R.write(Control_F_R); // 0:turn down 1:turn up + printf("Amber02\n"); + Control_F_R=1-Control_F_R; + printf("%d \n",Control_F_R); + wait(3); + } + if(limitSwitchUp == 0) + { + LiftingStopRun.write(1); // 0:Run 1:Stop + F_R.write(1); // 0:turn down 1:turn up + printf("Amber03\n"); + } + if(limitSwitchDown == 0) + { + LiftingStopRun.write(1); // 0:Run 1:Stop + F_R.write(0); // 0:turn down 1:turn up + printf("Amber04\n"); + } + + + //LiftingStopRun.write(1); +// F_R.write(1); +// limitSwitchUp = LimitSwitchUp.read(); +// limitSwitchDown = LimitSwitchDown.read(); +// if(!mybutton) +// { +// control_mybutton=1-control_mybutton; +// Control_LiftingStopRun=0; +// Control_F_R=1; +// +// LiftingStopRun.write(Control_LiftingStopRun); // 0:Run 1:Stop +// F_R.write(Control_F_R); // 0:turn down 1:turn up +// +// if(limitSwitchUp == 0) +// { +// Control_LiftingStopRun=1; +// Control_F_R=1; +// LiftingStopRun.write(Control_LiftingStopRun); // 0:Run 1:Stop +// F_R.write(Control_F_R); // 0:turn down 1:turn up +// } +// } +// if(mybutton == 1-control_mybutton) +// { +// control_mybutton=control_mybutton; +// Control_LiftingStopRun=0; +// Control_F_R=0; +// LiftingStopRun.write(Control_LiftingStopRun); // 0:Run 1:Stop +// F_R.write(Control_F_R); // 0:turn down 1:turn up +// if(limitSwitchDown == 0) +// { +// Control_LiftingStopRun=1; +// Control_F_R=0; +// LiftingStopRun.write(Control_LiftingStopRun); // 0:Run 1:Stop +// F_R.write(Control_F_R); // 0:turn down 1:turn up +// } +// } + + //printf(" %d | %d\n", limitSwitchUp,limitSwitchDown); +// printf(" %d \n", mybutton); + wait_ms(0.1); + } +} \ No newline at end of file
diff -r 000000000000 -r 3c119cb9fc49 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Sep 20 20:36:02 2017 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/mbed_official/code/mbed/builds/e2bfab296f20 \ No newline at end of file