self-balancing-robot
Dependencies: mbed mbed-rtos Motor
Diff: main.cpp
- Revision:
- 30:b1718c4edcd7
- Parent:
- 29:ed9f7144a6a7
- Child:
- 31:aa1ea0973c96
--- a/main.cpp Thu Apr 23 20:14:44 2020 +0000 +++ b/main.cpp Thu Apr 23 20:18:51 2020 +0000 @@ -1,6 +1,7 @@ #include "mbed.h" #include "rtos.h" #include "LSM9DS1.h" +#include "Motor.h" /////////////////////////////////////////////////////////////////////////////// @@ -37,8 +38,8 @@ float angleBias = 0; -PwmOut leftWheel(p21); -PwmOut rightWheel(p22); +Motor leftWheel(p21, p24, p23); // pwm, fwd, rev leftWheel(p21); +Motor rightWheel(p22, p26, p25); // pwm, fwd, rev rightWheel(p22); /////////////////////////////////////////////////////////////////////////////// @@ -129,8 +130,8 @@ void set_wheel_speed(float speed) { if(speed > 1) speed = 1; if (speed < -1) speed = -1; - leftWheel = speed; - rightWheel = speed; + leftWheel.speed(speed); + rightWheel.speed(speed); } @@ -203,8 +204,8 @@ //bluetooth.attach(&bluetooth_update, 0.1); while (1) { - leftWheel=1; - rightWheel=1; + leftWheel.speed(1); + rightWheel.speed(1); Thread::wait(10000); //bluetooth_update(); //parametersmutex.lock();