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.
Dependencies: mbed
main.cpp
- Committer:
- kaipon
- Date:
- 2021-11-18
- Revision:
- 1:7466e08b66e7
- Parent:
- 0:2da7c2bc2ed5
File content as of revision 1:7466e08b66e7:
#include "mbed.h" PwmOut pinAFin(D10); PwmOut pinARin(A1); PwmOut pinBFin(D11); PwmOut pinBRin(D12); void driveMotor(int speedA,int speedB) { float outputA = abs(speedA); float outputB = abs(speedB); if (speedA > 0) { pinAFin=outputA; pinARin=0; } else if (speedA < 0) { pinAFin=0; pinARin=outputA; } else { pinAFin=0; pinARin=0; } if (speedB > 0) { pinBFin=outputB; pinBRin=0; } else if (speedB < 0) { pinBFin=0; pinBRin=outputB; } else { pinBFin=0; pinBRin=0; } } int main() { wait(10); driveMotor(1,1); wait(10); driveMotor(0,0); return 0; }