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.
main.cpp@2:b64a41a187d8, 2018-01-13 (annotated)
- Committer:
- venhy
- Date:
- Sat Jan 13 11:45:48 2018 +0000
- Revision:
- 2:b64a41a187d8
- Parent:
- 1:81949e0b4a8f
Final
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
venhy | 0:efaf3e54119b | 1 | #include "mbed.h" |
venhy | 0:efaf3e54119b | 2 | #include "USBSerial.h" |
venhy | 0:efaf3e54119b | 3 | |
venhy | 2:b64a41a187d8 | 4 | DigitalOut myLed(LED1); |
venhy | 2:b64a41a187d8 | 5 | DigitalIn digitalOutputPIR(PTB0); |
venhy | 2:b64a41a187d8 | 6 | AnalogIn analogOutputPIR(A1); |
venhy | 2:b64a41a187d8 | 7 | USBSerial serial; |
venhy | 0:efaf3e54119b | 8 | |
venhy | 0:efaf3e54119b | 9 | int main() { |
venhy | 0:efaf3e54119b | 10 | |
venhy | 2:b64a41a187d8 | 11 | float analogValue = 0; |
venhy | 2:b64a41a187d8 | 12 | |
venhy | 0:efaf3e54119b | 13 | while(1) { |
venhy | 2:b64a41a187d8 | 14 | |
venhy | 2:b64a41a187d8 | 15 | analogValue = float(analogOutputPIR); |
venhy | 2:b64a41a187d8 | 16 | myLed = !digitalOutputPIR; |
venhy | 0:efaf3e54119b | 17 | |
venhy | 2:b64a41a187d8 | 18 | serial.printf("%f", 255*analogValue); //posli analogovou hodnotu na UART |
venhy | 0:efaf3e54119b | 19 | serial.printf(" "); |
venhy | 2:b64a41a187d8 | 20 | |
venhy | 2:b64a41a187d8 | 21 | if(digitalOutputPIR) serial.printf("50\r\n"); //posli hodnotu logickeho vystupu na UART (50 = log. 1, scaling osy Y) |
venhy | 2:b64a41a187d8 | 22 | else serial.printf("0\r\n"); |
venhy | 2:b64a41a187d8 | 23 | wait_ms(10); |
venhy | 0:efaf3e54119b | 24 | |
venhy | 0:efaf3e54119b | 25 | } |
venhy | 0:efaf3e54119b | 26 | } |
venhy | 0:efaf3e54119b | 27 |