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.
pwm.cpp
- Committer:
- Weranest
- Date:
- 2018-02-21
- Revision:
- 3:c9df852ad9ac
- Parent:
- 1:12f18cede014
- Child:
- 4:48d390356fba
File content as of revision 3:c9df852ad9ac:
//this defines motor setup and movement #include "mbed.h" #include "C12832.h" #include "pins.h" #include "pwm.h" #include "constants.cpp" //will have to determine real pulsewidths by testing with encoder //currently the setup uses unipolar mode, hence the need for direction void motorSetup(){ motorRight.period_ms(MOTOR_PERIOD); motorLeft.period_ms(MOTOR_PERIOD); motorDirLeft.write(0); motorDirRight.write(0); motorModeLeft.write(0); //1 =bipolar, 0 = unipolar motorModeRight.write(0); 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 buggyStop(){// no power motorRight.write(0.0f); motorLeft.write(0.0f); } void buggyStop(){// no power motorRight.write(0.0f); motorLeft.write(0.0f); }