Car 2: Electric Boogaloo

Dependencies:   camera mbed

Fork of Car2 by NXP Group 13

Code for an NXP Cup car using a linescan Camera

Committer:
zamatthews
Date:
Mon Feb 20 02:42:27 2017 +0000
Revision:
2:0db7cc5ad6db
Parent:
1:63c28aae78c9
Child:
3:dadfc15fc2d1
Use Pwm for Servo for now. Motor control still work in progress with no movement of motors yet.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
zamatthews 0:b761ef827157 1 #include "mbed.h"
zamatthews 2:0db7cc5ad6db 2 #include "Servo.h"
zamatthews 2:0db7cc5ad6db 3
zamatthews 2:0db7cc5ad6db 4 //Servo myServo(PTD4);
zamatthews 2:0db7cc5ad6db 5 //
zamatthews 2:0db7cc5ad6db 6 //int main(){
zamatthews 2:0db7cc5ad6db 7 // while(1){
zamatthews 2:0db7cc5ad6db 8 // for(float p=0; p<1.0; p += 0.1) {
zamatthews 2:0db7cc5ad6db 9 // myServo = p;
zamatthews 2:0db7cc5ad6db 10 // wait(0.2);
zamatthews 2:0db7cc5ad6db 11 // }
zamatthews 2:0db7cc5ad6db 12 // }
zamatthews 2:0db7cc5ad6db 13 //}
zamatthews 2:0db7cc5ad6db 14
zamatthews 0:b761ef827157 15
zamatthews 2:0db7cc5ad6db 16
zamatthews 2:0db7cc5ad6db 17 PwmOut servo(PTD4);
zamatthews 2:0db7cc5ad6db 18 PwmOut leftMotor(PTA12);
zamatthews 2:0db7cc5ad6db 19 PwmOut rightMotor(PTA4);
zamatthews 2:0db7cc5ad6db 20 DigitalOut DIR_L(PTC4);
zamatthews 2:0db7cc5ad6db 21 DigitalOut DIR_R(PTC5);
zamatthews 2:0db7cc5ad6db 22
zamatthews 2:0db7cc5ad6db 23 int main() {
zamatthews 2:0db7cc5ad6db 24 leftMotor.period_us(50);
zamatthews 2:0db7cc5ad6db 25 rightMotor.period_us(50);
zamatthews 2:0db7cc5ad6db 26 leftMotor.write(0.25);
zamatthews 2:0db7cc5ad6db 27 rightMotor.write(0.25);
zamatthews 2:0db7cc5ad6db 28 DIR_L = 0;
zamatthews 2:0db7cc5ad6db 29 DIR_R = 1;
zamatthews 2:0db7cc5ad6db 30 while(1){
zamatthews 2:0db7cc5ad6db 31
zamatthews 2:0db7cc5ad6db 32 //for(float p=0.0001f; p<=0.0015f; p += 0.00005f) {
zamatthews 2:0db7cc5ad6db 33 // //servo.period(0.020f);
zamatthews 2:0db7cc5ad6db 34 // servo.pulsewidth(p);
zamatthews 2:0db7cc5ad6db 35 // wait(0.05);
zamatthews 2:0db7cc5ad6db 36 // }
zamatthews 2:0db7cc5ad6db 37 // for(float p=0.0015f; p>=0.0001f; p -= 0.00005f) {
zamatthews 2:0db7cc5ad6db 38 // //servo.period(0.020f);
zamatthews 2:0db7cc5ad6db 39 // servo.pulsewidth(p);
zamatthews 2:0db7cc5ad6db 40 // wait(0.05);
zamatthews 2:0db7cc5ad6db 41 // }
zamatthews 2:0db7cc5ad6db 42
zamatthews 0:b761ef827157 43 }
zamatthews 2:0db7cc5ad6db 44 }