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@0:b676db63060d, 2015-11-03 (annotated)
- Committer:
- wehner334
- Date:
- Tue Nov 03 21:39:44 2015 +0000
- Revision:
- 0:b676db63060d
- Child:
- 1:6e80ddd10594
changing stuff;
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 | 0:b676db63060d | 3 | Ticker toggle_led_ticker; |
wehner334 | 0:b676db63060d | 4 | Serial pc(SERIAL_TX, SERIAL_RX); |
wehner334 | 0:b676db63060d | 5 | PwmOut mypwm(D9); |
wehner334 | 0:b676db63060d | 6 | AnalogIn analog_zero(A0); |
wehner334 | 0:b676db63060d | 7 | AnalogIn analog_one(A1); |
wehner334 | 0:b676db63060d | 8 | //DigitalOut led1(LED1); |
wehner334 | 0:b676db63060d | 9 | float meas[2]; |
wehner334 | 0:b676db63060d | 10 | void measuereandsend() { |
wehner334 | 0:b676db63060d | 11 | meas[0] = analog_zero.read(); // Converts and read the analog input value (value from 0.0 to 1.0) |
wehner334 | 0:b676db63060d | 12 | // meas[1] = analog_one.read(); // Converts and read the analog input value (value from 0.0 to 1.0) |
wehner334 | 0:b676db63060d | 13 | meas[0] = meas[0] * 3300; // Change the value to be in the 0 to 3300 range |
wehner334 | 0:b676db63060d | 14 | pc.printf(" %.0f \n", meas[0]); |
wehner334 | 0:b676db63060d | 15 | // printf(" %.0f \n", meas[1]); |
wehner334 | 0:b676db63060d | 16 | //led1 = !led1; |
wehner334 | 0:b676db63060d | 17 | } |
wehner334 | 0:b676db63060d | 18 | |
wehner334 | 0:b676db63060d | 19 | int main() { |
wehner334 | 0:b676db63060d | 20 | |
wehner334 | 0:b676db63060d | 21 | pc.baud(57600); |
wehner334 | 0:b676db63060d | 22 | // Init the ticker with the address of the function (toggle_led) to be attached and the interval (100 ms) |
wehner334 | 0:b676db63060d | 23 | mypwm.period_ms(1000); |
wehner334 | 0:b676db63060d | 24 | mypwm.pulsewidth_ms(50); |
wehner334 | 0:b676db63060d | 25 | toggle_led_ticker.attach(&measuereandsend, 0.001); |
wehner334 | 0:b676db63060d | 26 | |
wehner334 | 0:b676db63060d | 27 | while (true) { |
wehner334 | 0:b676db63060d | 28 | // Do other things... |
wehner334 | 0:b676db63060d | 29 | } |
wehner334 | 0:b676db63060d | 30 | } |