Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of read_analog by
main.cpp@0:140f2dc46122, 2018-07-11 (annotated)
- Committer:
- yokotay
- Date:
- Wed Jul 11 09:28:45 2018 +0000
- Revision:
- 0:140f2dc46122
- Child:
- 1:732610676e2e
init
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yokotay | 0:140f2dc46122 | 1 | #include "mbed.h" |
yokotay | 0:140f2dc46122 | 2 | |
yokotay | 0:140f2dc46122 | 3 | AnalogIn analog_value(dp13); |
yokotay | 0:140f2dc46122 | 4 | |
yokotay | 0:140f2dc46122 | 5 | int main(void) |
yokotay | 0:140f2dc46122 | 6 | { |
yokotay | 0:140f2dc46122 | 7 | float meas, temp; |
yokotay | 0:140f2dc46122 | 8 | printf("\r\nAnalogIn example\r\n"); |
yokotay | 0:140f2dc46122 | 9 | while(1) { |
yokotay | 0:140f2dc46122 | 10 | meas = analog_value.read(); // Converts and read the analog input value (value from 0.0 to 1.0) |
yokotay | 0:140f2dc46122 | 11 | meas = meas * 3300; // Change the value to be in the 0 to 3300 range (mV) |
yokotay | 0:140f2dc46122 | 12 | temp = 0.1 * meas - 50; // for TMP36GT9Z |
yokotay | 0:140f2dc46122 | 13 | printf("measure = %.0f mV, temp = %.1f C\r\n", meas, temp); |
yokotay | 0:140f2dc46122 | 14 | wait(0.2); // 200 ms |
yokotay | 0:140f2dc46122 | 15 | } |
yokotay | 0:140f2dc46122 | 16 | } |
yokotay | 0:140f2dc46122 | 17 |