![](/media/cache/group/Display_Nokia_Insper_v01.jpg.50x50_q85.jpg)
12/mar ignicao funcionando
Dependencies: mbed reScale TextLCD
Diff: main.cpp
- Revision:
- 2:3c69c0772709
- Parent:
- 0:b5a9e0614efd
- Child:
- 3:9d22aa32b223
--- a/main.cpp Thu Feb 21 17:06:56 2013 +0000 +++ b/main.cpp Wed Apr 25 12:06:39 2018 +0000 @@ -1,12 +1,59 @@ #include "mbed.h" + +InterruptIn motora(D0); +InterruptIn movida(D1); + +DigitalOut ign(LED1); -DigitalOut myled(LED1); + +Timer tbase; +Ticker call; + +Serial pc(USBTX, USBRX); // tx, rx + +unsigned long int t_motora, t_movida; -int main() { - while(1) { - myled = 1; - wait(0.2); - myled = 0; - wait(0.2); +void tracao() +{ + tbase.stop(); + t_motora = tbase.read_us(); + tbase.reset(); + tbase.start(); +} + +void livre() +{ + tbase.stop(); + t_movida = tbase.read_us(); + tbase.reset(); + tbase.start(); +} + +void send() +{ + pc.printf("Tempo: %.3f Hz \n\r"); +} + +int main() +{ + + motora.fall(&tracao); // attach the address of the measure function to the rising edge + movida.fall(&livre); // attach the address of the measure function to the rising edge + + //call.attach(&send, 0.5); + + while(1) + { + + if(t_movida < t_motora) + { + ign=0; + wait(0.1); + } + + else + { + ign=1; + } } -} +} \ No newline at end of file