Oscar de Jesus Vasquez
/
Mata_iHand
proyecto biometrico
Diff: main.cpp
- Revision:
- 0:f836fc1bf1d7
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Jul 14 00:44:21 2017 +0000 @@ -0,0 +1,89 @@ +#include "mbed.h" +#include "beep.h" + +Beep buzzer(p21); +Ticker cut; + + +Serial bt(p28,p27); +Serial pc(USBTX,USBRX); + +AnalogIn s_bpm(p20); +AnalogIn s_temp(p19); + +DigitalOut beat(LED1); + +char c; +int setter=0; +float Threshold=2.615; +float bpm_val=0; +float temp_val=0; +int beatc=0; + + + +void send_bpm() +{ + beatc=beatc*6; + if (beatc>130 || beatc<35) + { + buzzer.beep(1480,2); + } + bt.printf("%i %.2f\n\r",beatc,temp_val); + beatc=0; +} + void send_data() +{ + bpm_val=s_bpm*3.3; + temp_val=s_temp*3.3*100; + bt.printf("%.3f,%.3f\n\r",bpm_val,temp_val); +} + +int main() +{ +bt.baud(115200); + +while(setter == 0) +{ +if(bt.readable()) +{ +c = bt.getc(); +//bt.printf("%c\n\r",c); +setter=1; +} +} + +if(c =='a') +{ +//bt.printf("a selected\n\r"); +cut.attach(&send_bpm, 10.0); +} + +//if(c =='b') +//{ +//pc.printf("b selected\n\r"); +//cut.attach(&send_data,.1); +//} + +while(1) +{ + bpm_val=s_bpm*3.3; + temp_val=s_temp*3.3*100; + if(c =='b') + { + bt.printf("%.3f,%.3f\n\r",bpm_val,temp_val); + wait(.01); + } + + if(bpm_val > Threshold) + { + beat=1; + wait(.08); + beatc++; + } + else + { + beat=0; + } +} +} \ No newline at end of file