L073 Read Analog Value

Dependencies:   mbed

Committer:
shivanandgowdakr
Date:
Mon Sep 16 14:37:28 2019 +0000
Revision:
0:797df2d3d34b
Simple STM32L073 Read Analog Values

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shivanandgowdakr 0:797df2d3d34b 1 #include "mbed.h"
shivanandgowdakr 0:797df2d3d34b 2
shivanandgowdakr 0:797df2d3d34b 3 DigitalOut myled(LED1);
shivanandgowdakr 0:797df2d3d34b 4 AnalogIn battery(PA_5);
shivanandgowdakr 0:797df2d3d34b 5 float battery_value = 0;
shivanandgowdakr 0:797df2d3d34b 6 int main() {
shivanandgowdakr 0:797df2d3d34b 7 while(1) {
shivanandgowdakr 0:797df2d3d34b 8 battery_value = battery;
shivanandgowdakr 0:797df2d3d34b 9 myled = 1; // LED is ON
shivanandgowdakr 0:797df2d3d34b 10 wait(0.2); // 200 ms
shivanandgowdakr 0:797df2d3d34b 11 myled = 0; // LED is OFF
shivanandgowdakr 0:797df2d3d34b 12 wait(1.0); // 1 sec
shivanandgowdakr 0:797df2d3d34b 13 }
shivanandgowdakr 0:797df2d3d34b 14 }