![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
vježba 3a
main.cpp@0:1d1430d5fd6b, 2013-11-26 (annotated)
- Committer:
- cvitas
- Date:
- Tue Nov 26 17:44:47 2013 +0000
- Revision:
- 0:1d1430d5fd6b
vje?ba 3 a
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cvitas | 0:1d1430d5fd6b | 1 | /*Program Example 5.4: Reads input voltage through the ADC, and transfers to PC terminal |
cvitas | 0:1d1430d5fd6b | 2 | */ |
cvitas | 0:1d1430d5fd6b | 3 | #include "mbed.h" |
cvitas | 0:1d1430d5fd6b | 4 | Serial pc(USBTX, USBRX); //enable serial port which links to USB |
cvitas | 0:1d1430d5fd6b | 5 | AnalogIn Ain(p20); |
cvitas | 0:1d1430d5fd6b | 6 | |
cvitas | 0:1d1430d5fd6b | 7 | float ADCdata; |
cvitas | 0:1d1430d5fd6b | 8 | |
cvitas | 0:1d1430d5fd6b | 9 | int main() { |
cvitas | 0:1d1430d5fd6b | 10 | pc.printf("ADC Data Values...\n\r"); //send an opening text message |
cvitas | 0:1d1430d5fd6b | 11 | while(1){ |
cvitas | 0:1d1430d5fd6b | 12 | ADCdata=Ain; |
cvitas | 0:1d1430d5fd6b | 13 | wait(0.5); |
cvitas | 0:1d1430d5fd6b | 14 | pc.printf("%1.3f \n\r",ADCdata); //send the data to the terminal |
cvitas | 0:1d1430d5fd6b | 15 | } |
cvitas | 0:1d1430d5fd6b | 16 | } |