Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
main.cpp
- Committer:
- pbarrows
- Date:
- 2019-04-10
- Revision:
- 0:8b55e947c1eb
File content as of revision 0:8b55e947c1eb:
#include "mbed.h"
AnalogIn sensor(A1);
int main() {
float val;
val=sensor.read(); //read the ADC value from pin PA1
//VOLTAGE / STEP = REFERENCE VOLTAGE / 4096 = (3.6V/4096= 0.879mV) per unit.
float voltage=(val/4096)*3.6; //converts ADC value to voltage
while(1) {
printf("%.4f\n", voltage); // 0.0 to 1.0
wait_ms(100);}
}