ADC internal channels read example.
Dependencies: mbed
main.cpp@5:bc100134b571, 2017-06-07 (annotated)
- Committer:
- arostm
- Date:
- Wed Jun 07 14:31:20 2017 +0000
- Revision:
- 5:bc100134b571
- Parent:
- 4:e784c25594d7
- Child:
- 6:3e184b0bcc33
Adding new mbed library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bcostm | 0:bd554f9d9a54 | 1 | #include "mbed.h" |
bcostm | 0:bd554f9d9a54 | 2 | |
bcostm | 4:e784c25594d7 | 3 | /* |
bcostm | 4:e784c25594d7 | 4 | This basic example just shows how to read the ADC internal channels raw values. |
bcostm | 4:e784c25594d7 | 5 | Please look in the corresponding device reference manual for a complete |
bcostm | 4:e784c25594d7 | 6 | description of how to make a temperature sensor, VBat or Vref measurement. |
bcostm | 4:e784c25594d7 | 7 | */ |
bcostm | 1:55c36e464885 | 8 | |
bcostm | 4:e784c25594d7 | 9 | AnalogIn adc_temp(ADC_TEMP); |
bcostm | 4:e784c25594d7 | 10 | AnalogIn adc_vref(ADC_VREF); |
bcostm | 4:e784c25594d7 | 11 | AnalogIn adc_vbat(ADC_VBAT); // Warning: Not available on all devices |
bcostm | 0:bd554f9d9a54 | 12 | |
bcostm | 0:bd554f9d9a54 | 13 | DigitalOut led(LED1); |
bcostm | 0:bd554f9d9a54 | 14 | |
bcostm | 0:bd554f9d9a54 | 15 | int main() |
bcostm | 0:bd554f9d9a54 | 16 | { |
bcostm | 4:e784c25594d7 | 17 | printf("\nSTM32 ADC internal channels reading example\n"); |
bcostm | 0:bd554f9d9a54 | 18 | while(1) { |
bcostm | 4:e784c25594d7 | 19 | printf("ADC Temp = %f\n", adc_temp.read()); |
bcostm | 4:e784c25594d7 | 20 | printf("ADC VRef = %f\n", adc_vref.read()); |
bcostm | 4:e784c25594d7 | 21 | printf("ADC VBat = %f\n", adc_vbat.read()); |
bcostm | 4:e784c25594d7 | 22 | printf("\033[3A"); |
bcostm | 0:bd554f9d9a54 | 23 | led = !led; |
bcostm | 0:bd554f9d9a54 | 24 | wait(1.0); |
bcostm | 0:bd554f9d9a54 | 25 | } |
bcostm | 0:bd554f9d9a54 | 26 | } |