ADC values read in two formats are printed on PC terminal.
Dependencies: mbed
simple_AD_serial.cpp@0:0d95cd35c02a, 2018-05-10 (annotated)
- Committer:
- titanium
- Date:
- Thu May 10 02:25:35 2018 +0000
- Revision:
- 0:0d95cd35c02a
- Child:
- 1:9178a2aee69f
First version. Only main.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
titanium | 0:0d95cd35c02a | 1 | #include "mbed.h" |
titanium | 0:0d95cd35c02a | 2 | Serial pc(USBTX, USBRX); |
titanium | 0:0d95cd35c02a | 3 | AnalogIn adin(p20); |
titanium | 0:0d95cd35c02a | 4 | |
titanium | 0:0d95cd35c02a | 5 | main() |
titanium | 0:0d95cd35c02a | 6 | { float adval; |
titanium | 0:0d95cd35c02a | 7 | int iadval; |
titanium | 0:0d95cd35c02a | 8 | pc.printf("simple AD\n\r"); |
titanium | 0:0d95cd35c02a | 9 | while (1) { |
titanium | 0:0d95cd35c02a | 10 | adval=adin; |
titanium | 0:0d95cd35c02a | 11 | iadval=adin.read_u16(); |
titanium | 0:0d95cd35c02a | 12 | pc.printf("AD= %d %f\n\r", iadval, adval); |
titanium | 0:0d95cd35c02a | 13 | wait(0.5); } |
titanium | 0:0d95cd35c02a | 14 | } |
titanium | 0:0d95cd35c02a | 15 |