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

Dependencies:   mbed

main.cpp

Committer:
johannes_otto
Date:
2015-10-12
Revision:
0:46797506f6f3
Child:
1:f99510926784

File content as of revision 0:46797506f6f3:

#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);
    }
}