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.
main.cpp
- Committer:
- Kaikestu
- Date:
- 2010-02-12
- Revision:
- 2:6d5f8ddf1145
- Parent:
- 1:86868f4b226a
File content as of revision 2:6d5f8ddf1145:
#include "mbed.h"
#include "Servo.h"
DigitalOut myled(LED1);
DigitalOut myled2(LED2);
InterruptIn w(p16);
Timer timer;
LocalFileSystem local("local");
Servo serv (p21);
int begin,end;
int begin2,end2,ws;
int single_spin;
int count;
float i = 0.5;
void trigger() {
begin = timer.read_ms();
single_spin = begin - end;
end = timer.read_ms();
begin2 = timer.read_ms();
FILE *fp = fopen("/local/out.csv", "a");
count = count + 1;
myled2 = !myled2;
fprintf(fp, "%d, %d, %d, %.2f\n", count, single_spin, ws, i);
fclose(fp);
end2 = timer.read_ms();
ws = end2 - begin2;
end = end - ws;
}
int main() {
timer.start();
w.rise(&trigger);
FILE *fp = fopen("/local/out.csv", "a");
fprintf(fp, "Turn_No, Time(ms), Write_time(ms), servo_setting\n");
fclose(fp);
while (1) { // set this so it dont keep smashing in to walls !
serv.write(0.01);
wait(0.5);
i -= 0.01;
myled = !myled;
if (i <= 0 ){
break;
}
}
serv.write(0.5);
}