Shivanand Gowda
/
L073_Test
L073 Read Analog Value
main.cpp@0:797df2d3d34b, 2019-09-16 (annotated)
- 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?
User | Revision | Line number | New 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 | } |