Intrrupt, scanf , printf, Timer
Dependencies: mbed
Revision 0:c7377fa95fab, committed 2015-10-15
- Comitter:
- madmonkeyman82
- Date:
- Thu Oct 15 15:54:42 2015 +0000
- Commit message:
- first
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Thu Oct 15 15:54:42 2015 +0000
@@ -0,0 +1,44 @@
+#include "mbed.h"
+
+InterruptIn SW7(PB_3);
+InterruptIn SW6(PA_10);
+
+Timer timer;
+
+void startKlokke();
+void stoppKlokke();
+void print();
+
+int main()
+{
+
+ printf("Velkommen\n");
+
+ SW7.fall(&startKlokke);
+ SW6.fall(&stoppKlokke);
+
+ while(1)
+ {
+
+ }
+
+}
+void startKlokke()
+{
+ timer.reset();
+ timer.start();
+}
+
+void stoppKlokke()
+{
+ timer.stop();
+ print();
+}
+
+void print()
+{
+ float tidSek=timer.read();
+ float hastighet = (5/tidSek)*3.6;
+
+ printf("Hastighet %.2f Km\\t\r\n", hastighet);
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Oct 15 15:54:42 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/ba1f97679dad \ No newline at end of file