Reading analog input with an STM32F103C8T6 board. ADC is calibrated to achieve higher accuracy.
Reading analog input with STM32F103C8T6 board
Import the program into your online compiler.
Schematic
main.cpp
- Committer:
- hudakz
- Date:
- 2019-02-05
- Revision:
- 2:b0563c2ef616
- Parent:
- 1:7522adef9bd0
File content as of revision 2:b0563c2ef616:
#include "mbed.h" #include "AnalogIn.h" const float REF_VOLT = 3300; // Reference voltage in millivolts Serial pc(PA_2, PA_3); DigitalOut myled(PC_13); AnalogIn analogIn(PA_0); // Create an analog input float voltage; int main() { while (1) { voltage = analogIn.read() * REF_VOLT; // convert analog to digital pc.printf("voltage = %.0f mV\r\n", voltage); myled = !myled; wait_ms(1000); } }