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: camera mbed tsi_sensor
Fork of Car2 by
Diff: main.cpp
- Revision:
- 13:9175be9c2b9e
- Parent:
- 12:4ccf304800fe
- Child:
- 14:c6f0a3c4e222
--- a/main.cpp Tue Mar 21 01:42:19 2017 +0000 +++ b/main.cpp Wed Mar 22 20:19:03 2017 +0000 @@ -1,5 +1,4 @@ #include "mbed.h" -#include "Servo.h" #include "Camera.h" #define STRAIGHT 0.00095f #define FULLRIGHT 0.0013f @@ -8,7 +7,7 @@ #define MAX_TURN_RATIO 0.7 #define MIN_SPEED 0.1 #define MAX_SPEED 0.6 -#define TURN_TIME 100 +#define TURN_TIME 50 PwmOut servo(PTE20); PwmOut motor_left(PTA5); @@ -17,7 +16,6 @@ DigitalOut DIR_R(PTA4); Serial pc(USBTX, USBRX); Camera cam(PTE23, PTE21, PTB3); - int turnCounter = 0; float wheelPos = STRAIGHT; @@ -50,7 +48,7 @@ } float averagePos = 0; - if (numDarks == 0) { + if (numDarks == 0 && turnCounter >= (TURN_TIME / 2)) { wheelPos = STRAIGHT; } @@ -88,7 +86,6 @@ } int main() { - //timer.start(); motor_left.period_us(50); motor_right.period_us(50); DIR_R = 1;