![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
analog
Diff: main.cpp
- Revision:
- 1:cf19fbe2bbef
- Parent:
- 0:9f88863531a6
- Child:
- 2:0f44305ad45c
--- a/main.cpp Sun Mar 19 10:17:20 2017 +0000 +++ b/main.cpp Sun Mar 19 10:50:42 2017 +0000 @@ -4,22 +4,25 @@ DigitalOut led1 (LED1); AnalogIn analog (A0); -Serial pc(USBTX,USBRX); +Serial serial(PA_2,PA_3); int main() -{ - pc.baud(115200); +{ uint16_t a0_val =0; + float a0_volt=0; + bool light=false; + serial.baud(115200); while (true) { - uint16_t a0_val = analog.read_u16(); - float a0_volt = ((float)a0_val/65535)*3.3; - - wait_ms(15); - pc.printf("Hodnota a0_val (16bit): %d\n", a0_val); - pc.printf("Napeti na vstupu A0: %.3f\n",a0_volt); - pc.printf("\n"); - - - led1 = !led1; - wait(1); + 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); + + } }