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: LineFollowingRobot/main.cpp
- Revision:
- 4:645b5d648c64
- Parent:
- 3:54c41af9e119
- Child:
- 5:bb0bec710c91
diff -r 54c41af9e119 -r 645b5d648c64 LineFollowingRobot/main.cpp --- a/LineFollowingRobot/main.cpp Sun Feb 03 16:42:44 2019 +0000 +++ b/LineFollowingRobot/main.cpp Wed Feb 06 14:02:07 2019 +0000 @@ -19,7 +19,7 @@ - Backwards PWM : PTA4 - Forward PWM : PTA5 -Motor Left Control : +Motor Right Control : - Motor Enable : PTA13 - Backwards PWM : PTD5 - Forward PWM : PTD0 @@ -61,11 +61,21 @@ //waits for an interrupt to occur, then performs all the calculations if(toggleIR != IRSensor.m_toggle){ - IRSensor.WeightPID(); - IRSensor.CalculatePID(); + //IRSensor.WeightPID(); + //IRSensor.CalculatePID(); IRSensor.MotorControl(controlLeft,controlRight); + if(IRSensor.m_dirL != IRSensor.m_prevDirL) controlLeft.SetDirection(IRSensor.m_dirL); + if(IRSensor.m_dirR != IRSensor.m_prevDirR) controlRight.SetDirection(IRSensor.m_dirR); + + controlLeft.SetSpeed(abs(IRSensor.m_speedL)); + controlRight.SetSpeed(abs(IRSensor.m_speedR)); + + IRSensor.m_prevDirL = IRSensor.m_dirL; + IRSensor.m_prevDirR = IRSensor.m_dirR; + + printf("toggle %d", toggleIR); toggleIR = IRSensor.m_toggle; - } + } } } \ No newline at end of file