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/RobotControl.cpp
- Revision:
- 3:54c41af9e119
- Parent:
- 0:a02a278513d9
- Child:
- 4:645b5d648c64
--- a/LineFollowingRobot/RobotControl.cpp Sat Feb 02 16:38:08 2019 +0000
+++ b/LineFollowingRobot/RobotControl.cpp Sun Feb 03 16:42:44 2019 +0000
@@ -6,10 +6,14 @@
/*class constructor : initializes the motors with
forward enable and speed of 0.3 */
- m_dir = true;
- m_speed = 0.3;
- SetDirection(m_dir);
- SetSpeed(m_speed);
+ //m_dir = true;
+ //m_speed = 0.2;
+
+ m_motorBw.period_ms(1);
+ m_motorFw.period_ms(1);
+
+ SetDirection(1);
+ SetSpeed(0.2);
}
@@ -39,11 +43,10 @@
/*set speed on the pwm which is point by m_pwmPtr (set by SetDirection)
speed : the speed given to the motor, ranges from 0 to 1*/
- if(speed<=1.0 && speed > 0.0){
- m_pwmPtr->write(speed);
- }else{
- m_pwmPtr->write(0);
- }
+ if(speed<=0) m_pwmPtr->write(0);
+ else if(speed>=1.0)m_pwmPtr->write(1.0);
+ else m_pwmPtr->write(speed);
+
}