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 PE_05-04_LoggingData by
main.cpp@0:ec4e2bc1996f, 2012-10-15 (annotated)
- Committer:
- robt
- Date:
- Mon Oct 15 21:18:35 2012 +0000
- Revision:
- 0:ec4e2bc1996f
- Child:
- 1:a8d819e5c10d
by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| robt | 0:ec4e2bc1996f | 1 | /*Program Example 5.4: Reads input voltage through the ADC, and transfers to PC terminal |
| robt | 0:ec4e2bc1996f | 2 | */ |
| robt | 0:ec4e2bc1996f | 3 | #include "mbed.h" |
| robt | 0:ec4e2bc1996f | 4 | Serial pc(USBTX, USBRX); //enable serial port which links to USB |
| robt | 0:ec4e2bc1996f | 5 | AnalogIn Ain(p20); |
| robt | 0:ec4e2bc1996f | 6 | |
| robt | 0:ec4e2bc1996f | 7 | float ADCdata; |
| robt | 0:ec4e2bc1996f | 8 | |
| robt | 0:ec4e2bc1996f | 9 | int main() { |
| robt | 0:ec4e2bc1996f | 10 | pc.printf("ADC Data Values...\n\r"); //send an opening text message |
| robt | 0:ec4e2bc1996f | 11 | while(1){ |
| robt | 0:ec4e2bc1996f | 12 | ADCdata=Ain; |
| robt | 0:ec4e2bc1996f | 13 | wait(0.5); |
| robt | 0:ec4e2bc1996f | 14 | pc.printf("%1.3f \n\r",ADCdata); //send the data to the terminal |
| robt | 0:ec4e2bc1996f | 15 | } |
| robt | 0:ec4e2bc1996f | 16 | } |
| robt | 0:ec4e2bc1996f | 17 |
