BME3915(NBDJZ) / Mbed 2 deprecated LDRVoltageCircuitDigest

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);}
}