easytronic / Mbed 2 deprecated Nucleo_read_analog_value

Dependencies:   testmotor mbed

main.cpp

Committer:
mijimy
Date:
2016-01-18
Revision:
3:999285691154
Parent:
1:0490a15c76e4
Child:
4:cad5a10b7007

File content as of revision 3:999285691154:

#include "mbed.h"
#include "TextLCD.h"

TextLCD lcd(p9,p10); 
AnalogIn analog_value(p20);
Serial pc ( USBTX , USBRX ) ; 
DigitalOut led(LED1);

int main() {
    float meas;
    
    printf("\nAnalogIn example\n");
    
    while(1) {
        meas = analog_value; // Converts and read the analog input value (value from 0.0 to 1.0)
        meas = meas * 3.3; // Change the value to be in the 0 to 3300 range
        printf("measure = %.3f V\n", meas);
        lcd.locate(4,2);
         lcd.printf("measure = %.3f V", meas);
        if (meas > 2) { // If the value is greater than 2V then switch the LED on
          led = 1;
        }
        else {
          led = 0;
        }
        wait(0.5); // 200 ms
    }
}