EKG 2Channel
Dependencies: mbed
Hello this a simple program that reads the ADC Value of pin A0 and A1 and displays them on the serial port /media/uploads/wehner334/ekg_andreas.xlsx
main.cpp@2:153e3258be9b, 2016-02-26 (annotated)
- Committer:
- wehner334
- Date:
- Fri Feb 26 10:09:06 2016 +0000
- Revision:
- 2:153e3258be9b
- Parent:
- 1:6e80ddd10594
new version;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wehner334 | 0:b676db63060d | 1 | #include "mbed.h" |
wehner334 | 0:b676db63060d | 2 | |
wehner334 | 1:6e80ddd10594 | 3 | //Ticker toggle_led_ticker; |
wehner334 | 1:6e80ddd10594 | 4 | Ticker debug_ticker; |
wehner334 | 0:b676db63060d | 5 | Serial pc(SERIAL_TX, SERIAL_RX); |
wehner334 | 0:b676db63060d | 6 | PwmOut mypwm(D9); |
wehner334 | 0:b676db63060d | 7 | AnalogIn analog_zero(A0); |
wehner334 | 0:b676db63060d | 8 | AnalogIn analog_one(A1); |
wehner334 | 0:b676db63060d | 9 | //DigitalOut led1(LED1); |
wehner334 | 2:153e3258be9b | 10 | Timer Timerone; |
wehner334 | 0:b676db63060d | 11 | float meas[2]; |
wehner334 | 2:153e3258be9b | 12 | int Timervalue=0; |
wehner334 | 0:b676db63060d | 13 | void measuereandsend() { |
wehner334 | 2:153e3258be9b | 14 | Timervalue=Timerone.read_ms(); |
wehner334 | 0:b676db63060d | 15 | meas[0] = analog_zero.read(); // Converts and read the analog input value (value from 0.0 to 1.0) |
wehner334 | 2:153e3258be9b | 16 | meas[1] = analog_one.read(); // Converts and read the analog input value (value from 0.0 to 1.0) |
wehner334 | 2:153e3258be9b | 17 | meas[0] = meas[0] * 3300; |
wehner334 | 2:153e3258be9b | 18 | meas[1]=meas[1]*3300; // Change the value to be in the 0 to 3300 range |
wehner334 | 2:153e3258be9b | 19 | pc.printf("%i, %.0f,%.0f\n",Timervalue, meas[0],meas[1]); |
wehner334 | 0:b676db63060d | 20 | // printf(" %.0f \n", meas[1]); |
wehner334 | 0:b676db63060d | 21 | //led1 = !led1; |
wehner334 | 0:b676db63060d | 22 | } |
wehner334 | 0:b676db63060d | 23 | |
wehner334 | 1:6e80ddd10594 | 24 | /*void debugprint() |
wehner334 | 1:6e80ddd10594 | 25 | {pc.printf("%.0f \n", 5000.0); |
wehner334 | 1:6e80ddd10594 | 26 | } |
wehner334 | 1:6e80ddd10594 | 27 | */ |
wehner334 | 0:b676db63060d | 28 | int main() { |
wehner334 | 2:153e3258be9b | 29 | Timerone.start(); |
wehner334 | 2:153e3258be9b | 30 | pc.baud(230400); |
wehner334 | 0:b676db63060d | 31 | // Init the ticker with the address of the function (toggle_led) to be attached and the interval (100 ms) |
wehner334 | 1:6e80ddd10594 | 32 | // mypwm.period(1000.0); |
wehner334 | 1:6e80ddd10594 | 33 | //mypwm.write(0.001); |
wehner334 | 1:6e80ddd10594 | 34 | //debug_ticker.attach(&debugprint, 1.0); |
wehner334 | 1:6e80ddd10594 | 35 | //toggle_led_ticker.attach(&measuereandsend, 0.001); |
wehner334 | 0:b676db63060d | 36 | |
wehner334 | 0:b676db63060d | 37 | while (true) { |
wehner334 | 2:153e3258be9b | 38 | if(Timervalue>1000) |
wehner334 | 2:153e3258be9b | 39 | {Timerone.reset();} |
wehner334 | 1:6e80ddd10594 | 40 | measuereandsend(); |
wehner334 | 1:6e80ddd10594 | 41 | |
wehner334 | 1:6e80ddd10594 | 42 | |
wehner334 | 0:b676db63060d | 43 | // Do other things... |
wehner334 | 0:b676db63060d | 44 | } |
wehner334 | 0:b676db63060d | 45 | } |