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: main.cpp
- Revision:
- 8:1ce513eff545
- Parent:
- 3:7ca21112a13d
- Child:
- 9:fd77a619181d
diff -r ae096a326a56 -r 1ce513eff545 main.cpp --- a/main.cpp Fri Dec 04 05:31:17 2015 +0000 +++ b/main.cpp Fri Dec 04 05:56:00 2015 +0000 @@ -1,15 +1,39 @@ #include "mbed.h" -#include "util.h" + +#include "pid.h" + +Ticker Systicker; + + +//////setting the errors for PID +ctrl obj; + + + + + + + +void systick(){ //rotations + float error = rotationError(); + obj.updateErr(error); + float corr = obj.total(); + leftMotor.addToPwm(corr); + rightMotor.addToPwm(-corr); + + + + } + int main() { - while(1){ - pc.printf("L: %d\n", leftMotor.getPulses()); - pc.printf("R: %d\n", rightMotor.getPulses()); - - leftMotor.setPwm(1.0); - rightMotor.setPwm(1.0); - } + Systicker.attach_us(&systick,1000); + rightMotor.setPwm(1.0); + leftMotor.setPwm(1.0); + + + return 0; }