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:
- 5:137dfb3e692f
- Parent:
- 4:f4852befd69c
- Child:
- 6:971236e48adc
--- a/main.cpp Thu Mar 02 21:39:22 2017 +0000 +++ b/main.cpp Thu Mar 02 21:55:33 2017 +0000 @@ -14,7 +14,8 @@ //camera data pins used are (D0-D7): PTC7, PTC0, PTC3, PTC4, PTC5, PTC6, PTC10, PTC11 //other camera pins: SCL->PTE5, SDA->PTE4, PCLK->PTE21, VSYNC->PTE30, H->PTE29 PwmOut servo(PTE20); -PwmOut motor(PTA5); +PwmOut motor_left(PTA5); +PwmOut motor_right(PTC8); DigitalOut DIR_L(PTD4); DigitalOut DIR_R(PTA4); @@ -44,8 +45,9 @@ turnAngle -= STRAIGHT; //this gets a value from -0.00035 and +0.00035 turnAngle = abs(turnAngle); float turnRatio = turnAngle/0.00035f; - float newSpeed = (0.9*(1-turnRatio)/4)+0.1; - motor.write(newSpeed); + float newSpeed = (0.7*(1-turnRatio)/4)+0.3; + motor_left.write(newSpeed); + motor_right.write(newSpeed); } void turnWheels(){//int[][] frame, float speed){ @@ -76,9 +78,10 @@ int main() { //timer.start(); - motor.period_us(50); + motor_left.period_us(50); + motor_right.period_us(50); //motor.write(0.25); - DIR_R = 1; //what purpose do these lines serve? + DIR_R = 1; DIR_L = 0; servo.period(0.020f); //servo.pulsewidth(STRAIGHT);