![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
analog
main.cpp
- Committer:
- Tomsik
- Date:
- 2017-03-19
- Revision:
- 1:cf19fbe2bbef
- Parent:
- 0:9f88863531a6
- Child:
- 2:0f44305ad45c
File content as of revision 1:cf19fbe2bbef:
#include "mbed.h" DigitalOut led1 (LED1); AnalogIn analog (A0); Serial serial(PA_2,PA_3); int main() { uint16_t a0_val =0; float a0_volt=0; bool light=false; serial.baud(115200); while (true) { a0_val = analog.read_u16(); a0_volt = ((float)a0_val/65535)*3.3; light=a0_volt<1.5; led1=light; serial.printf("Hodnota a0_val (16bit): %d\n\r", a0_val); serial.printf("Napeti na vstupu A0: %.3f\n\r",a0_volt); wait_ms(100); } }