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.
Fork of Liniensensor_Bendel by
Revision 4:e7be677a73e5, committed 2016-03-14
- Comitter:
- schoeni_91
- Date:
- Mon Mar 14 18:19:29 2016 +0000
- Parent:
- 3:b6754e794335
- Commit message:
- Version 2
Changed in this revision
LinienSensor_Pendel.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 b6754e794335 -r e7be677a73e5 LinienSensor_Pendel.cpp --- a/LinienSensor_Pendel.cpp Mon Mar 14 17:16:26 2016 +0000 +++ b/LinienSensor_Pendel.cpp Mon Mar 14 18:19:29 2016 +0000 @@ -9,9 +9,11 @@ Timer t1, t2; AnalogInHL ls1(p18), ls2(p16), ls3(p20), ls4(p19), ls5(p17); - +void FollowUntilEnd (); +void TurnUntilLine(); int main(void) { + pex.WaitUntilFrontButtonPressed(); boardPow=3; wait_ms(10); InitBertl(); @@ -19,25 +21,58 @@ leds=9; pex.ClearLeds(); t1.start(); - t2.start(); - - while(1) { - pex.ReadButtons(); - if(pex.IsButton(BTN_FM)) - { - if (ls3.Read()>400) - { - mL.SetPow(0.1); - mR.SetPow(0.3); - } - else - { - mL.SetPow(0.3); - mR.SetPow(0.1); - } - } - + while(1) + { + wait_ms(1000); + FollowUntilEnd (); + wait_ms(1000); + TurnUntilLine(); } + while(1){} + return 1; } + +void FollowUntilEnd () +{ + t1.reset(); + while(1) { + + + if (ls3.Read()>400) { + mL.SetPow(0.0); + mR.SetPow(0.25); + t1.reset(); + } + + else { + mL.SetPow(0.25); + mR.SetPow(0.0); + } + + if (t1.read_ms()>500) { + mL.SetPow(0.0); + mR.SetPow(0.0); + return; + + } + + } + +} + +void TurnUntilLine() +{ + mL.SetPow2(0.15); + mR.SetPow2(-0.15); + + while(1){ + + if (ls3.Read()>400){ + mL.SetPow2(0.0); + mR.SetPow2(0.0); + return; + } + } + } \ No newline at end of file
diff -r b6754e794335 -r e7be677a73e5 mbed.bld --- a/mbed.bld Mon Mar 14 17:16:26 2016 +0000 +++ b/mbed.bld Mon Mar 14 18:19:29 2016 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/9ad691361fac \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/87f2f5183dfb \ No newline at end of file