SmartWheels self-driving race car. Designed for NXP Cup. Uses FRDM-KL25Z, area-scan camera, and simple image processing to detect and navigate any NXP spec track.
Dependencies: TSI USBDevice mbed-dev
Fork of SmartWheels by
main.cpp
- Committer:
- hazheng
- Date:
- 2017-02-01
- Revision:
- 3:c8867972ffc7
- Child:
- 4:25e028102625
- Child:
- 5:577b582e4fe9
File content as of revision 3:c8867972ffc7:
#include "mbed.h" #include "Camera.h" #include "USBHID.h" //We declare a USBHID device. Input out output reports have a length of 8 bytes USBHID hid(8, 8); //This report will contain data to be sent HID_REPORT send_report; HID_REPORT recv_report; Serial pc(USBTX, USBRX); int main(void) { Camera cam; send_report.length = 8; while (1) { //Fill the report for (int i = 0; i < send_report.length; i++) { send_report.data[i] = rand() & 0xff; } //Send the report hid.send(&send_report); //try to read a msg if(hid.readNB(&recv_report)) { pc.printf("recv: "); for(int i = 0; i < recv_report.length; i++) { pc.printf("%d ", recv_report.data[i]); } pc.printf("\r\n"); } wait(0.1); } } /* PwmOut servo(PTE20); int main() { servo.period(0.020); // servo requires a 20ms period while (1) { for(float offset=0.0; offset<0.001; offset+=0.0001) { servo.pulsewidth(0.001 + offset); // servo position determined by a pulsewidth between 1-2ms wait(0.25); } } } */