Init
Dependencies: Break Motor Communication Steering mbed Controller
main.cpp
- Committer:
- skrickl
- Date:
- 2017-07-13
- Revision:
- 1:2538cbbea1f8
- Parent:
- 0:226470cfa428
File content as of revision 1:2538cbbea1f8:
#include "mbed.h" #include "SerialController.h" #include "MbedToPC.h" #include "MotorController.h" #include <string> DigitalOut led1(LED1); DigitalOut led2(LED2); //DigitalOut led3(LED3); //DigitalOut led4(LED4); DigitalOut pin1(p21); DigitalOut pin2(p22); DigitalOut pin_forward(p29); DigitalOut pin_backward(p30); AnalogOut pin_analog_out_throttle(p18); Serial pc(USBTX, USBRX, 115200); int main() { pin1 = 0; pin2 = 0; SerialController controller(p9, p10, p28, p27, 115200); float speed = 0.0; int status = 0; int uno = 1; int zero = 0; led1 = uno; wait(1); led1 = zero; while (1) { /*led1 = !led1; wait(0.5);*/ status = controller.getStatus(); led1 = status; led2 = status; pc.printf("Status: %i \r\n",status); /*if (status == MbedToPC::STATUS_START) { speed = controller.getVelTarget(); led1 = 0; } else { speed = 0; led1 = 1; } if (speed == 0) { pin_analog_out_throttle = 0; pin_forward = 0; pin_backward = 0; } else if (speed < 0) { pin_analog_out_throttle = 0; pin_forward = 0; pin_backward = 1; wait_ms(100); pin_analog_out_throttle = 0.6; } else if (speed > 0) { pin_analog_out_throttle = 0; pin_backward = 0; pin_forward = 1; wait_ms(100); pin_analog_out_throttle = 0.6; }*/ } }