masamitsu shibata
/
traserTA_termA
タームAのプログラム
Revision 0:a1535b0b1c12, committed 2016-09-29
- Comitter:
- 12f2025e
- Date:
- Thu Sep 29 07:23:54 2016 +0000
- Commit message:
- ???A??????
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 a1535b0b1c12 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Sep 29 07:23:54 2016 +0000 @@ -0,0 +1,92 @@ +//リフト上げ条件センサ2つ + +#include "mbed.h" + +DigitalIn in1(PTE21);//左 +DigitalIn in2(PTE20);//左中 +DigitalIn in3(PTE23);//右中 +DigitalIn in4(PTE22);//右 + +DigitalOut led1(PTB8);//左 +DigitalOut led2(PTB9);//左中 +DigitalOut led3(PTB10);//右中 +DigitalOut led4(PTB11);//右 + +BusOut cmotor(PTA1,PTA2); +PwmOut vc(PTD4); +BusOut lmotor(PTC0,PTC7); +PwmOut vl(PTA12); +BusOut rmotor(PTC6,PTC5); +PwmOut vr(PTA4); + +int main() { + while(1) { + if(in1 == 1)//黒の時光る 1:白 0:黒 + led1 = 0;//1:光る 0:光らない + else + led1 = 1; + + if(in2 == 1) + led2 = 0; + else + led2 = 1; + + if(in3 == 1) + led3 = 0; + else + led3 = 1; + + if(in4 == 1) + led4 = 0; + else + led4 = 1; + + /////////////////////// + if(in2 == 0 && in3 == 0) + { + lmotor = 0; + vl = 0.0f; + rmotor = 1; + vr = 0.1f; + } + else if(in2 == 0 && in3 == 1) + { + lmotor = 0; + vl = 0.0f; + rmotor = 1; + vr = 0.1f; + } + else if(in2 == 1 && in3 == 0) + { + lmotor = 1; + vl = 0.1f; + rmotor = 1; + vr = 0.1f; + } + else + { + lmotor = 1; + vl = 0.1f; + rmotor = 0; + vr = 0.0f; + } + + if(in1 == 0 && in4 == 0) + { + cmotor = 1; + vc = 0.5f; + lmotor = 0; + vl = 0.0f; + rmotor = 0; + vr = 0.0f; + wait(0.5); + cmotor = 0; + vc = 0.0f; + lmotor = 0; + vl = 0.0f; + rmotor = 0; + vr = 0.0f; + wait(10); + } + } +} \ No newline at end of file
diff -r 000000000000 -r a1535b0b1c12 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Sep 29 07:23:54 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/abea610beb85 \ No newline at end of file