programmable ignition for an mz ts 150. The interruptor needs to be replaced by an hall effect sensor

Dependencies:   mbed

Revision:
0:46797506f6f3
Child:
1:f99510926784
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Oct 12 12:16:44 2015 +0000
@@ -0,0 +1,28 @@
+#include "mbed.h"
+InterruptIn interruptor(D2);
+Timer t;
+long round_time;
+float offset=34.14;
+float def_ignition=26.13;
+long ign_delay;
+DigitalOut ignition(D3);
+
+void ignite()
+{
+    t.stop();
+    round_time=t.read_us();
+    t.start();
+    ign_delay=round_time*(offset-def_ignition)/360;
+    wait_us(ign_delay-t.read_us());
+    ignition.write(1);
+    wait_us(100);
+    ignition.write(0);
+}
+
+int main()
+{
+    t.start();
+    while(1) {
+        interruptor.rise(&ignite);
+    }
+}
\ No newline at end of file