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: Break Motor Communication Steering mbed Controller
main.cpp
00001 #include "mbed.h" 00002 #include "SerialController.h" 00003 #include "MbedToPC.h" 00004 #include "MotorController.h" 00005 #include <string> 00006 00007 DigitalOut led1(LED1); 00008 DigitalOut led2(LED2); 00009 //DigitalOut led3(LED3); 00010 //DigitalOut led4(LED4); 00011 00012 DigitalOut pin1(p21); 00013 DigitalOut pin2(p22); 00014 00015 00016 DigitalOut pin_forward(p29); 00017 DigitalOut pin_backward(p30); 00018 AnalogOut pin_analog_out_throttle(p18); 00019 00020 Serial pc(USBTX, USBRX, 115200); 00021 00022 int main() 00023 { 00024 pin1 = 0; 00025 pin2 = 0; 00026 00027 SerialController controller(p9, p10, p28, p27, 115200); 00028 00029 float speed = 0.0; 00030 int status = 0; 00031 int uno = 1; 00032 int zero = 0; 00033 00034 led1 = uno; 00035 wait(1); 00036 led1 = zero; 00037 00038 while (1) 00039 { 00040 /*led1 = !led1; 00041 wait(0.5);*/ 00042 00043 status = controller.getStatus(); 00044 00045 led1 = status; 00046 led2 = status; 00047 00048 pc.printf("Status: %i \r\n",status); 00049 00050 /*if (status == MbedToPC::STATUS_START) 00051 { 00052 speed = controller.getVelTarget(); 00053 led1 = 0; 00054 } 00055 else 00056 { 00057 speed = 0; 00058 led1 = 1; 00059 } 00060 00061 if (speed == 0) 00062 { 00063 pin_analog_out_throttle = 0; 00064 pin_forward = 0; 00065 pin_backward = 0; 00066 } 00067 else if (speed < 0) 00068 { 00069 pin_analog_out_throttle = 0; 00070 pin_forward = 0; 00071 pin_backward = 1; 00072 wait_ms(100); 00073 pin_analog_out_throttle = 0.6; 00074 } 00075 else if (speed > 0) 00076 { 00077 pin_analog_out_throttle = 0; 00078 pin_backward = 0; 00079 pin_forward = 1; 00080 wait_ms(100); 00081 pin_analog_out_throttle = 0.6; 00082 }*/ 00083 } 00084 }
Generated on Thu Jul 14 2022 00:29:41 by
1.7.2