Code for the car to drive in a figure eight motion

Dependencies:   mbed-rtos mbed MODSERIAL mbed-dsp telemetry

main.cpp

Committer:
ericoneill
Date:
2015-03-20
Revision:
17:3b545dc0c800
Parent:
14:09d61b20b102
Parent:
16:fa13ac00f583
Child:
18:16f1297a4260
Child:
21:a9e9aa7da8db

File content as of revision 17:3b545dc0c800:

#include "mbed.h"
#include "rtos.h"
#include "telemetry.h"

// Camera Pins
DigitalOut clk(PTA13);
DigitalOut si(PTD4);
AnalogIn camData(PTC2);
//Servo, Motor, Serial Pins
PwmOut servo(PTA5);
PwmOut motor1(PTA4);
PwmOut motor2(PTA12);
DigitalOut break1(PTC12);
DigitalOut break2(PTC13);
Serial pc(USBTX, USBRX);
// Interrupt for encoder
InterruptIn interrupt(PTA13);

float line [128];
Mutex line_mutex;

void linecam_thread(void const *args){
    while(1){
        line_mutex.lock();
        pc.printf("[");
        for(int i=0; i<128; i++){
            pc.printf("%f",line[i]);
            pc.printf(" ");
        }
        pc.printf("]");
    }
    
}


int main() {
    Thread thread(linecam_thread);
    thread.set_priority(osPriorityIdle);
    //thread.set_priority(-3);
    
    int integrationCounter = 0;
    while(1) {
        if(integrationCounter % 151== 0){
            
        }
        else if (integrationCounter > 129){
        }
        else{
            clk = 1;
            wait_us(50);
            line[integrationCounter - 1] = camData;
            clk = 0;
        }
        
        integrationCounter++;
    }
}