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: IRSensorPID.cpp
- Revision:
- 1:d96e4201ff84
- Parent:
- 0:9d67126e11c8
--- a/IRSensorPID.cpp Fri Jan 25 14:09:48 2019 +0000
+++ b/IRSensorPID.cpp Sat Jan 26 16:09:10 2019 +0000
@@ -67,7 +67,7 @@
pwmRight.motorBw.write(0);
pwmRight.motorFw.write(0);
- wait(0.1);
+ wait(0.001);
if(!direction){
pwmRight.motorEnable = false;
@@ -90,7 +90,7 @@
if(speed<=1.0 && speed > 0.0){
pwmLeftPtr->write(speed);
pwmRightPtr->write(speed);
- }else if(speed < 0 && speed >= 1.0){
+ }else if(speed < 0 && speed >= 1.0){
SetDirection(0, 0);
SetDirection(0, 1);
}
@@ -207,7 +207,7 @@
float highThresh = 0.2, lowThresh = 0.2;
float maxPID = 5.0, minPID = -5.0;
- int dirLeft, dirRight;
+ bool dirLeft, dirRight;
bool left
//assign new speed with PID value and scale it
@@ -219,10 +219,10 @@
rightSpeed = initSpeed + PIDValue;
leftSpeed > 0 ? dirLeft = true : dirLeft = false;
- if(leftSpeed == prevDir.prevDirL) setDirection(...);
+ if(leftSpeed != prevDir.prevDirL) setDirection(...);
righSpeed > 0 ? dirRight = true : dirRight = false;
- if(rightSpeed == prevDir.prevDirR) setDirection(...);
+ if(rightSpeed != prevDir.prevDirR) setDirection(...);
SetSpeed(...)