SwitchMode
Dependencies: BEAR_Protocol InverseLeg iSerial mbed
Fork of SwitchMode by
Revision 8:f17874479d80, committed 2016-02-03
- Comitter:
- soulx
- Date:
- Wed Feb 03 17:48:58 2016 +0000
- Parent:
- 7:3935c7dcc9c5
- Commit message:
- show 20th fibo
Changed in this revision
InverseLeg.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 3935c7dcc9c5 -r f17874479d80 InverseLeg.lib --- a/InverseLeg.lib Thu Jan 28 15:23:43 2016 +0000 +++ b/InverseLeg.lib Wed Feb 03 17:48:58 2016 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/teams/BEaR-lab/code/InverseLeg/#a2a5ebd65f46 +http://mbed.org/teams/BEaR-lab/code/InverseLeg/#444a33819962
diff -r 3935c7dcc9c5 -r f17874479d80 main.cpp --- a/main.cpp Thu Jan 28 15:23:43 2016 +0000 +++ b/main.cpp Wed Feb 03 17:48:58 2016 +0000 @@ -536,7 +536,7 @@ if(a == true && b == true && c == true && d == true) { float LHipAngle,LKneeAngle; float RHipAngle,RKneeAngle; - + bcom.getMotorPos(LEFT_SIDE,&LHipAngle,&LKneeAngle); wait_ms(90); bcom.getMotorPos(RIGHT_SIDE,&RHipAngle,&RKneeAngle); @@ -742,6 +742,11 @@ int main() { + Timer counterUP; + Timer counterLOW; + + char state[2]; + float temp[2]; pc.baud(115200); pc.printf("Start\n"); @@ -751,7 +756,49 @@ while(!button); SwMode(); } + sync_communicate.stop(); + counterUP.start(); + counterLOW.start(); + + state[0] =0; + state[1] =0; + + temp[0] =20; + temp[1] =5; + + while(1) { + + if(counterUP.read_ms() > 1400) { + if(state[0] ==0) { + temp[0] = 20; + state[0]=1; + } else { + temp[0] = 50; + state[0]=0; + } + counterUP.reset(); + + } + + if(counterLOW.read_ms() > 700) { + if(state[1] ==0) { + temp[1] = 5; + state[1]=1; + } else { + temp[1] = 90; + state[1]=0; + } + + counterLOW.reset(); + + } + + + bcom.setMotorPos(LEFT_SIDE,temp[0],temp[1]); + bcom.setMotorPos(RIGHT_SIDE,temp[0],temp[1]); + + } }