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
00001 #include "mbed.h" 00002 #include "Servo.h" 00003 00004 00005 DigitalOut myled(LED1); 00006 DigitalOut myled2(LED2); 00007 InterruptIn w(p16); 00008 Timer timer; 00009 LocalFileSystem local("local"); 00010 Servo serv (p21); 00011 00012 int begin,end; 00013 int begin2,end2,ws; 00014 int single_spin; 00015 int count; 00016 float i = 0.5; 00017 00018 void trigger() { 00019 00020 begin = timer.read_ms(); 00021 single_spin = begin - end; 00022 end = timer.read_ms(); 00023 00024 00025 begin2 = timer.read_ms(); 00026 FILE *fp = fopen("/local/out.csv", "a"); 00027 count = count + 1; 00028 myled2 = !myled2; 00029 fprintf(fp, "%d, %d, %d, %.2f\n", count, single_spin, ws, i); 00030 fclose(fp); 00031 00032 end2 = timer.read_ms(); 00033 ws = end2 - begin2; 00034 end = end - ws; 00035 } 00036 00037 00038 int main() { 00039 timer.start(); 00040 w.rise(&trigger); 00041 FILE *fp = fopen("/local/out.csv", "a"); 00042 fprintf(fp, "Turn_No, Time(ms), Write_time(ms), servo_setting\n"); 00043 fclose(fp); 00044 00045 while (1) { // set this so it dont keep smashing in to walls ! 00046 00047 serv.write(0.01); 00048 wait(0.5); 00049 i -= 0.01; 00050 myled = !myled; 00051 00052 if (i <= 0 ){ 00053 break; 00054 } 00055 00056 } 00057 00058 serv.write(0.5); 00059 00060 00061 00062 }
Generated on Tue Nov 29 2022 04:53:15 by
1.7.2