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:
Bobymicjohn
Date:
Thu Feb 02 23:30:41 2017 +0000
Revision:
4:25e028102625
Parent:
3:c8867972ffc7
Child:
6:0682e1c90119
Added motor class;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hazheng 3:c8867972ffc7 1 #include "mbed.h"
Bobymicjohn 4:25e028102625 2
Bobymicjohn 4:25e028102625 3 //#include "Motor.h"
hazheng 3:c8867972ffc7 4
hazheng 3:c8867972ffc7 5
Bobymicjohn 4:25e028102625 6 PwmOut servo(PTE20);
Bobymicjohn 4:25e028102625 7
Bobymicjohn 4:25e028102625 8 //DigitalOut DIR_L(PTA13, 1);
Bobymicjohn 4:25e028102625 9 //DigitalOut DIR_R(PTC9, 1);
Bobymicjohn 4:25e028102625 10
Bobymicjohn 4:25e028102625 11 //PwmOut PWM_L(PTD0);
Bobymicjohn 4:25e028102625 12 //PwmOut PWM_R(PTD5);
Bobymicjohn 4:25e028102625 13
Bobymicjohn 4:25e028102625 14 int main(void) {
Bobymicjohn 4:25e028102625 15 servo.period(0.020);
Bobymicjohn 4:25e028102625 16 //Motor motor;
Bobymicjohn 4:25e028102625 17
Bobymicjohn 4:25e028102625 18 //PWM_L.period_us(60);
Bobymicjohn 4:25e028102625 19 //PWM_R.period_us(60);
Bobymicjohn 4:25e028102625 20
hazheng 3:c8867972ffc7 21 while (1) {
Bobymicjohn 4:25e028102625 22 //motor.setLeftSpeed(20);
Bobymicjohn 4:25e028102625 23 //motor.setRightSpeed(20);
Bobymicjohn 4:25e028102625 24 //PWM_L.pulsewidth_us(60);
Bobymicjohn 4:25e028102625 25 //PWM_R.pulsewidth_us(60);
Bobymicjohn 4:25e028102625 26 //servo.pulsewidth(0.0015);
hazheng 3:c8867972ffc7 27
Bobymicjohn 4:25e028102625 28 for(float offset=0.0; offset<0.001; offset+=0.0001)
Bobymicjohn 4:25e028102625 29 {
Bobymicjohn 4:25e028102625 30 servo.pulsewidth(0.001 + offset); // servo position determined by a pulsewidth between 1-2ms
Bobymicjohn 4:25e028102625 31 wait(0.25);
hazheng 3:c8867972ffc7 32 }
hazheng 3:c8867972ffc7 33
hazheng 3:c8867972ffc7 34 wait(0.1);
hazheng 3:c8867972ffc7 35 }
hazheng 3:c8867972ffc7 36 }
hazheng 3:c8867972ffc7 37
hazheng 3:c8867972ffc7 38 /*
hazheng 3:c8867972ffc7 39 PwmOut servo(PTE20);
hazheng 3:c8867972ffc7 40
hazheng 3:c8867972ffc7 41 int main() {
hazheng 3:c8867972ffc7 42 servo.period(0.020); // servo requires a 20ms period
hazheng 3:c8867972ffc7 43
hazheng 3:c8867972ffc7 44 while (1) {
hazheng 3:c8867972ffc7 45 for(float offset=0.0; offset<0.001; offset+=0.0001) {
hazheng 3:c8867972ffc7 46 servo.pulsewidth(0.001 + offset); // servo position determined by a pulsewidth between 1-2ms
hazheng 3:c8867972ffc7 47 wait(0.25);
hazheng 3:c8867972ffc7 48 }
hazheng 3:c8867972ffc7 49 }
hazheng 3:c8867972ffc7 50
hazheng 3:c8867972ffc7 51 }
hazheng 3:c8867972ffc7 52 */