v1.1 of orig program, slowly speeds up motor to find the poit at witch it gets stuck in the trigger or reaches top speed

Dependencies:   mbed

main.cpp

Committer:
Kaikestu
Date:
2010-02-05
Revision:
1:86868f4b226a
Parent:
0:8fab2b18d87d
Child:
2:6d5f8ddf1145

File content as of revision 1:86868f4b226a:

#include "mbed.h"
#include "Servo.h"


DigitalOut myled(LED1);
DigitalOut myled2(LED2);
InterruptIn w(p16);
Timer timer;
LocalFileSystem local("local");
Servo serv (p21);

int count,begin,end;
int single_spin;
const int wheel = 257; //in mm
int Tdist=0;
int i =0;

void trigger() {
    FILE *fp = fopen("/local/out.csv", "a");

    count = count + 1;
    begin = timer.read_ms();
    single_spin = begin - end;
    myled2 = !myled2;
    fprintf(fp, "%d, %d\n", count, single_spin);
    end = timer.read_ms();
    fclose(fp);

}


int main() {
    timer.start();
    w.rise(&trigger);

    while (count < 5 ) // set this so it dont keep smashing in to walls !
     {
        
        serv.write(0.3);
        myled = !myled;
        wait(0.1);
    }
  
    serv.write(0.5);



}