かいださん
Dependencies: mbed
Fork of 2016_Spring_kaida by
Diff: KaidaKari.cpp
- Revision:
- 15:5e973e6c058c
- Parent:
- 14:67ee8d8f4efe
- Child:
- 16:ea0808fbbb40
--- a/KaidaKari.cpp Mon Jun 06 12:22:38 2016 +0000 +++ b/KaidaKari.cpp Thu Jun 09 02:53:48 2016 +0000 @@ -7,10 +7,6 @@ int RSX,RSY,LSX,LSY,BSU,BSL; //これより下に関数外に書く要素を記入する -PwmOut led1(LED1); -PwmOut led2(LED2); -DigitalOut led3(LED3); -DigitalOut led4(LED4); //MD1 PwmOut motorRightOne (p25); @@ -22,13 +18,13 @@ //MD3 Arm1 PwmOut armRight(p22); -DigitalOut armOne (p29); -DigitalOut armTwo (p30); +DigitalOut armThree (p29); +DigitalOut armFour (p30); //MD4 Arm2 -PwmOut armLeft(p21); -DigitalOut armThree (p19); -DigitalOut armFour (p20); +PwmOut armLeft(p22); +DigitalOut armOne (p19); +DigitalOut armTwo (p20); /* @@ -61,8 +57,7 @@ I need to ask what to do with this! Actually, do we have any LEDs? */ - led1.period_ms(20); - led3=1; + } void UserLoop(char n,const u8* data) @@ -96,73 +91,86 @@ double fastSpeed = 1; double slowSpeed = 0.5; */ - + //motor - if( RSY>140 ) {//forward + if( LSY > 140 && (ButtonState >> BUTTONLANALOG)&1 == 1) { + motorRightOne = 0.8; + motorRightTwo = 0; + 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; motorRightTwo = 0; motorLeftOne = 0.4; motorLeftTwo = 0; - } else if( RSY<110 ) { //back + + } else if( LSY < 110 ) { //back motorRightOne = 0; motorRightTwo = 0.4; motorLeftOne = 0; motorLeftTwo = 0.4; - } else {//stop + } else { //stop motorRightOne = 0; motorRightTwo = 0; motorLeftOne = 0; motorLeftTwo = 0; } - -//turn left if(( ButtonState >> BUTTONR1)&1 == 1) { + motorRightOne = 0; + motorRightTwo = 0.4; + motorLeftOne = 0.4; + motorLeftTwo = 0; + } + if(( ButtonState >> BUTTONL1)&1 == 1) { motorRightOne = 0.4; motorRightTwo = 0; motorLeftOne = 0; - motorLeftTwo = 0.4; - } -//turn right - if(( ButtonState >> BUTTONL1)&1 == 1) { - motorLeftOne = 0; - motorLeftTwo = 0.4; - motorRightOne = 0.4; - motorRightTwo = 0; + motorLeftTwo = 0.4 + ; + } //arm - if( LSY>140 ) { + if( (ButtonState >> BUTTONL2)&1 == 1 ) { + armOne = 0; + armTwo = 1; + armRight = 0.8; + } else if( (ButtonState >> BUTTONR2)&1 == 1 ) { armOne = 1; armTwo = 0; armRight = 0.4; - } else if( RSY<110 ) { - armOne = 0; - armTwo = 1; - armRight = 0.4; } else { armOne = 0; armTwo = 0; armRight = 0; + } - if((ButtonState >> BUTTONCROSS)&1 == 1) { + if((ButtonState >> BUTTONTRIANGEL)&1 == 1) { armThree = 1; armFour = 0; armLeft = 0.4; - } else if((ButtonState >> BUTTONTRIANGEL)&1 == 1) { + } else if((ButtonState >> BUTTONCROSS)&1 == 1) { armThree = 0; armFour = 1; armLeft = 0.4; - }else{ + } else { armThree = 0; armFour = 0; armLeft = 0; } - if(( ButtonState >> BUTTONPC)&1 == 1) { + if(( ButtonState >> BUTTONPS)&1 == 1) { motorRightOne = 0; motorRightTwo = 0; @@ -172,8 +180,8 @@ armTwo = 0; armThree = 0; armFour = 0; - armRight = 0; - armLeft = 0; + + wait(1); } /* @@ -190,9 +198,6 @@ //○が押されたとき } - - led1=RSX/256.0f; - led2=RSY/256.0f; /* led3=ButtonState & 0x0400; //L1の状態 led4=ButtonState & 0x0800; //R1の状態