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.
Diff: pwm.cpp
- Revision:
- 4:48d390356fba
- Parent:
- 3:c9df852ad9ac
--- a/pwm.cpp Wed Feb 21 11:55:29 2018 +0000 +++ b/pwm.cpp Thu Feb 22 17:01:00 2018 +0000 @@ -20,46 +20,10 @@ driveBoard.write(1); //enables the buggy to drive } -if(joystickDown == 1){ -void buggyGoF(){ //drives forward - motorRight.write(NORMAL_PWM*potRight.read()); - motorLeft.write(NORMAL_PWM*potLeft.read()); -} -void buggyGoLeft(){// drives left - motorRight.write(FAST_PWM*potRight.read()); - motorLeft.write(SLOW_PWM*potLeft.read()); -} -void buggyGoRight(){ //drives right - motorRight.write(SLOW_PWM*potRight.read()); - motorLeft.write(FAST_PWM*potLeft.read()); -} -} - -else{ - void buggyGoF(){ //drives forward - motorRight.write(NORMAL_PWM); - motorLeft.write(NORMAL_PWM); -} - -void buggyGoLeft(){// drives left - motorRight.write(FAST_PWM); - motorLeft.write(SLOW_PWM); -} -void buggyGoRight(){ //drives right - motorRight.write(SLOW_PWM); - motorLeft.write(FAST_PWM); -} +void buggyPWM(float pwmLeft, float pwmRight){ //drives forward + motorRight.write(pwmRight); + motorLeft.write(pwmLeft); } -void buggyStop(){// no power - motorRight.write(0.0f); - motorLeft.write(0.0f); -} - - -void buggyStop(){// no power - motorRight.write(0.0f); - motorLeft.write(0.0f); -} \ No newline at end of file