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 Servo ros_lib_kinetic
Diff: Motors/Motor.cpp
- Revision:
- 10:51dd168b5a96
- Parent:
- 9:326b8f261ef0
- Child:
- 11:12e73437dc9f
--- a/Motors/Motor.cpp Sat Jan 04 21:35:25 2020 +0000 +++ b/Motors/Motor.cpp Mon Jan 06 20:38:07 2020 +0000 @@ -15,6 +15,8 @@ cMotor MotorL(M1_PWM, M1_IN1, M1_IN2); //Left motor class and pin initialisation cMotor MotorR(M2_PWM, M2_IN1, M2_IN2); //Right motor class and pin initialisation +float *TOFrangePtr[4]; + //Servo servo1(srvoTilt); //Servo servo2(srvoPan); @@ -117,7 +119,16 @@ MotorL.Backwards(1.0f); wait(0.387); } - + + //Stop command + else if (keyPress.data == 'q') { + MotorR.Stop(); + MotorL.Stop(); + } + //Stop command + else if (keyPress.data == 'e') { + Check_for_obstacles(*TOFrangePtr); + } else { MotorR.Stop(); @@ -142,7 +153,7 @@ Output Parameters: N/A Description: Simple obstacle avoidance functionality ----------------------------------------------------------------------------------*/ -void Check_for_obstacles(uint8_t TOFRange[4]) +void Check_for_obstacles(float TOFRange[4]) { //If top right sensor(6) detects something if (TOFRange[2]<200) {