Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 2:b64a41a187d8
- Parent:
- 1:81949e0b4a8f
diff -r 81949e0b4a8f -r b64a41a187d8 main.cpp --- a/main.cpp Wed Jan 10 17:55:14 2018 +0000 +++ b/main.cpp Sat Jan 13 11:45:48 2018 +0000 @@ -1,27 +1,26 @@ #include "mbed.h" #include "USBSerial.h" - -DigitalOut myled(LED1); -DigitalIn dig(PTB0); -AnalogIn pir(A1); -USBSerial serial; +DigitalOut myLed(LED1); +DigitalIn digitalOutputPIR(PTB0); +AnalogIn analogOutputPIR(A1); +USBSerial serial; int main() { - float val = 0; - float jedna = 50.000; - float nula = 0.500; - + float analogValue = 0; + while(1) { + + analogValue = float(analogOutputPIR); + myLed = !digitalOutputPIR; - val = float(pir); - myled = dig; - serial.printf("%f", 255*val); + serial.printf("%f", 255*analogValue); //posli analogovou hodnotu na UART serial.printf(" "); - if(dig) serial.printf("%f\r\n",jedna); - else serial.printf("%f\r\n",nula); - wait(0.01); + + if(digitalOutputPIR) serial.printf("50\r\n"); //posli hodnotu logickeho vystupu na UART (50 = log. 1, scaling osy Y) + else serial.printf("0\r\n"); + wait_ms(10); } }