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
Diff: main.cpp
- Revision:
- 6:0682e1c90119
- Parent:
- 4:25e028102625
- Parent:
- 5:577b582e4fe9
- Child:
- 8:92f6baeea027
--- a/main.cpp Thu Feb 02 23:30:41 2017 +0000 +++ b/main.cpp Fri Feb 03 04:06:50 2017 +0000 @@ -2,33 +2,51 @@ //#include "Motor.h" +//#include "Camera.h" + +#include "USBHIDServer.h" PwmOut servo(PTE20); - //DigitalOut DIR_L(PTA13, 1); //DigitalOut DIR_R(PTC9, 1); - //PwmOut PWM_L(PTD0); //PwmOut PWM_R(PTD5); +DigitalOut led(LED1, 1); int main(void) { servo.period(0.020); + + //Camera cam; + //Motor motor; //PWM_L.period_us(60); //PWM_R.period_us(60); - while (1) { - //motor.setLeftSpeed(20); - //motor.setRightSpeed(20); - //PWM_L.pulsewidth_us(60); - //PWM_R.pulsewidth_us(60); - //servo.pulsewidth(0.0015); + USBHIDServer server; + + unsigned int testCount = 0; + unsigned int testCount2 = 0; + char buf[5]; + + //motor.setLeftSpeed(20); + //motor.setRightSpeed(20); + //PWM_L.pulsewidth_us(60); + //PWM_R.pulsewidth_us(60); + //servo.pulsewidth(0.0015); - for(float offset=0.0; offset<0.001; offset+=0.0001) + while (1) + { + led = 0; + server.Update(0.0f); + testCount++; + if(testCount >= 10000) { - servo.pulsewidth(0.001 + offset); // servo position determined by a pulsewidth between 1-2ms - wait(0.25); + testCount2++; + sprintf(buf, "%d", testCount2); + //server.PushUnreliableMsg('D', "Test Message!"); + server.PushUnreliableMsg('D', buf); + testCount = 0; } wait(0.1);