Mbed master / Mbed 2 deprecated LAB03_Oppgave2

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 InterruptIn SW7(PB_3);
00004 InterruptIn SW6(PA_10);
00005     static double tidSek;
00006     //static double meter=5;
00007     //static double kmh=3.6;
00008     //static double v;
00009       
00010     Timer timer;
00011     
00012     void startKlokke()
00013     {
00014     timer.reset();
00015     timer.start();
00016     }
00017 
00018     void stopKlokke()
00019     {
00020     timer.stop();
00021     tidSek=timer.read_ms()/1000.0;
00022     //v=meter/tidSek*kmh;
00023 
00024     
00025     printf("Km/t %.3f \r\n", 5/tidSek*3.6 );
00026     }
00027 
00028     int main ()
00029 {
00030     
00031     SW7.fall(&startKlokke);
00032     SW6.fall(&stopKlokke);     
00033      
00034     
00035 
00036     while (true)
00037     {     
00038     timer.reset();
00039     while (SW7==1){;};
00040     timer.start();
00041     while (SW6==1){;};
00042     timer.stop();
00043            
00044          
00045            wait_ms(200);
00046            
00047     }
00048 }