jack kemnitz
/
Nucleo_read_analog_value
hjk
Diff: main.cpp
- Revision:
- 0:de6bbe463c29
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Jul 26 20:02:01 2017 +0000 @@ -0,0 +1,24 @@ +#include "mbed.h" + +AnalogIn analog_value(A0); + +Serial pc(SERIAL_TX, SERIAL_RX); + + +int main() { + + FILE *f = fopen("pressuredata.txt", "w"); + float meas; + + printf("\nAnalogIn example\n"); + + while(1) { + meas = analog_value.read(); // + //meas = meas * 3300; // Change the value to be in the 0 to 3300 range + printf("Pressure Value = %.0f mV\n", meas); + fprintf(f, "Pressure Value: %s\n", meas); + wait(0.2); // 200 ms + } + + fclose(f); +}