Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of clubvs2017_momoi by
Diff: KaidaKari.cpp
- Revision:
- 17:efe67bbb927e
- Parent:
- 16:ea0808fbbb40
- Child:
- 18:cab2885dc8fe
--- a/KaidaKari.cpp Fri Jun 10 04:49:54 2016 +0000 +++ b/KaidaKari.cpp Fri Jun 10 06:05:29 2016 +0000 @@ -7,24 +7,24 @@ int RSX,RSY,LSX,LSY,BSU,BSL; //これより下に関数外に書く要素を記入する - +double flag; //MD1 -PwmOut motorRightOne (p25); -PwmOut motorRightTwo (p26); +PwmOut motorRightOne (p23); +PwmOut motorRightTwo (p24); //MD2 -PwmOut motorLeftOne (p24); -PwmOut motorLeftTwo (p23); +PwmOut motorLeftOne (p21); +PwmOut motorLeftTwo (p22); //MD3 Arm1 -PwmOut armRight(p22); -DigitalOut armThree (p29); -DigitalOut armFour (p30); +PwmOut armRight(p26); +DigitalOut armThree (p30); +DigitalOut armFour (p29); //MD4 Arm2 -PwmOut armLeft(p22); -DigitalOut armOne (p19); -DigitalOut armTwo (p20); +PwmOut armLeft(p25); +DigitalOut armOne (p6); +DigitalOut armTwo (p5); /* @@ -93,18 +93,35 @@ */ //motor - - if( LSY > 140 ) { //forward - motorRightOne = 0.4; + if((ButtonState >> BUTTONPS)&1 == 1){ + flag = 0; + }else if((ButtonState >> BUTTONSTART)&1 == 1) { + flag += 0.05; + } else if((ButtonState >> BUTTONSELECT)&1 == 1) { + flag -= 0.05; + } + + if(LSY>140 && ((ButtonState >> BUTTONLANALOG)&1) == 1) { + motorRightOne = 0.8; motorRightTwo = 0; - motorLeftOne = 0.4; + motorLeftOne = 0.8; + motorLeftTwo = 0; + }else if(LSY<110 && ((ButtonState >> BUTTONLANALOG)&1) == 1) { + motorRightOne = 0; + motorRightTwo = 0.8; + motorLeftOne = 0; + motorLeftTwo = 0.8; + }else if( LSY > 140 ) { //forward + motorRightOne = 0.4 + flag; + motorRightTwo = 0; + motorLeftOne = 0.4 + flag; motorLeftTwo = 0; } else if( LSY < 110 ) { //back motorRightOne = 0; - motorRightTwo = 0.4; + motorRightTwo = 0.4 + flag; motorLeftOne = 0; - motorLeftTwo = 0.4; + motorLeftTwo = 0.4 + flag; } else { //stop motorRightOne = 0; motorRightTwo = 0; @@ -114,65 +131,66 @@ if(( ButtonState >> BUTTONR1)&1 == 1) { motorRightOne = 0; - motorRightTwo = 0.4; - motorLeftOne = 0.4; + motorRightTwo = 0.4 + flag; + motorLeftOne = 0.4 + flag; motorLeftTwo = 0; } if(( ButtonState >> BUTTONL1)&1 == 1) { - motorRightOne = 0.4; + motorRightOne = 0.4 + flag; motorRightTwo = 0; motorLeftOne = 0; - motorLeftTwo = 0.4; + motorLeftTwo = 0.4 + flag; } //arm if( (ButtonState >> BUTTONUP)&1 == 1 ) { + armThree = 0; + armFour = 1; + armLeft = 0.4; + } else if( (ButtonState >> BUTTONDOWN)&1 == 1 ) { + armThree = 1; + armFour = 0; + armLeft = 0.4; + } else { + armThree = 0; + armFour = 0; + armLeft = 0; + + } + + if((ButtonState >> BUTTONSQUARE)&1 == 1) { + armOne = 1; + armTwo = 0; + armRight = 0.4; + } else if((ButtonState >> BUTTONCIRCLE)&1 == 1) { armOne = 0; armTwo = 1; - armRight = 0.8; - } else if( (ButtonState >> BUTTONDOWN)&1 == 1 ) { - armOne = 1; - armTwo = 0; armRight = 0.4; } else { armOne = 0; armTwo = 0; armRight = 0; - } +printf("%f ",flag); - if((ButtonState >> BUTTONTRIANGEL)&1 == 1) { - armThree = 1; - armFour = 0; - armLeft = 0.4; - } else if((ButtonState >> BUTTONCROSS)&1 == 1) { - armThree = 0; - armFour = 1; - armLeft = 0.4; - } else { - armThree = 0; - armFour = 0; - armLeft = 0; + /* + With oen if, put both arms and legs. - - /* - With oen if, put both arms and legs. - - Use start and select?? + Use start and select?? - */ + */ - /* - led3=ButtonState & 0x0400; //L1の状態 - led4=ButtonState & 0x0800; //R1の状態 - */ //値の取得はps3.hを参照 + /* + led3=ButtonState & 0x0400; //L1の状態 + led4=ButtonState & 0x0800; //R1の状態 + */ //値の取得はps3.hを参照 - + } } \ No newline at end of file