by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"
main.cpp@0:ec4e2bc1996f, 2012-10-15 (annotated)
- Committer:
- robt
- Date:
- Mon Oct 15 21:18:35 2012 +0000
- Revision:
- 0:ec4e2bc1996f
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 |