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 haofan Zheng

Committer:
hazheng
Date:
Fri Feb 03 03:59:42 2017 +0000
Revision:
5:577b582e4fe9
Parent:
3:c8867972ffc7
Child:
6:0682e1c90119
Added USB Server. (Not the best solution.)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hazheng 3:c8867972ffc7 1 #include "mbed.h"
hazheng 5:577b582e4fe9 2
hazheng 3:c8867972ffc7 3 #include "Camera.h"
hazheng 5:577b582e4fe9 4
hazheng 5:577b582e4fe9 5 #include "USBHIDServer.h"
hazheng 5:577b582e4fe9 6
hazheng 5:577b582e4fe9 7 DigitalOut led(LED1, 1);
hazheng 5:577b582e4fe9 8
hazheng 3:c8867972ffc7 9 int main(void) {
hazheng 5:577b582e4fe9 10 //Camera cam;
hazheng 5:577b582e4fe9 11 USBHIDServer server;
hazheng 5:577b582e4fe9 12 unsigned int testCount = 0;
hazheng 5:577b582e4fe9 13 unsigned int testCount2 = 0;
hazheng 5:577b582e4fe9 14 char buf[5];
hazheng 5:577b582e4fe9 15
hazheng 5:577b582e4fe9 16 while (1)
hazheng 5:577b582e4fe9 17 {
hazheng 5:577b582e4fe9 18 led = 0;
hazheng 5:577b582e4fe9 19 server.Update(0.0f);
hazheng 5:577b582e4fe9 20 testCount++;
hazheng 5:577b582e4fe9 21 if(testCount >= 10000)
hazheng 5:577b582e4fe9 22 {
hazheng 5:577b582e4fe9 23 testCount2++;
hazheng 5:577b582e4fe9 24 sprintf(buf, "%d", testCount2);
hazheng 5:577b582e4fe9 25 //server.PushUnreliableMsg('D', "Test Message!");
hazheng 5:577b582e4fe9 26 server.PushUnreliableMsg('D', buf);
hazheng 5:577b582e4fe9 27 testCount = 0;
hazheng 3:c8867972ffc7 28 }
hazheng 5:577b582e4fe9 29 //wait(0.01);
hazheng 3:c8867972ffc7 30 }
hazheng 3:c8867972ffc7 31 }
hazheng 3:c8867972ffc7 32
hazheng 3:c8867972ffc7 33 /*
hazheng 3:c8867972ffc7 34 PwmOut servo(PTE20);
hazheng 3:c8867972ffc7 35
hazheng 3:c8867972ffc7 36 int main() {
hazheng 3:c8867972ffc7 37 servo.period(0.020); // servo requires a 20ms period
hazheng 3:c8867972ffc7 38
hazheng 3:c8867972ffc7 39 while (1) {
hazheng 3:c8867972ffc7 40 for(float offset=0.0; offset<0.001; offset+=0.0001) {
hazheng 3:c8867972ffc7 41 servo.pulsewidth(0.001 + offset); // servo position determined by a pulsewidth between 1-2ms
hazheng 3:c8867972ffc7 42 wait(0.25);
hazheng 3:c8867972ffc7 43 }
hazheng 3:c8867972ffc7 44 }
hazheng 3:c8867972ffc7 45
hazheng 3:c8867972ffc7 46 }
hazheng 3:c8867972ffc7 47 */