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.
Dependencies: mbed
Fork of Oppgave4-4 by
main.cpp@1:e6e3af75f623, 2014-10-17 (annotated)
- Committer:
- tors
- Date:
- Fri Oct 17 15:39:20 2014 +0000
- Revision:
- 1:e6e3af75f623
- Parent:
- 0:c26cdf21261a
.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tors | 0:c26cdf21261a | 1 | #include "mbed.h" |
tors | 0:c26cdf21261a | 2 | DigitalOut LR(p18); |
tors | 1:e6e3af75f623 | 3 | DigitalIn B1(p15); |
tors | 1:e6e3af75f623 | 4 | float t = 2.0; |
tors | 0:c26cdf21261a | 5 | int main() |
tors | 0:c26cdf21261a | 6 | { |
tors | 1:e6e3af75f623 | 7 | |
tors | 0:c26cdf21261a | 8 | while(1) { |
tors | 1:e6e3af75f623 | 9 | if(!B1) |
tors | 1:e6e3af75f623 | 10 | { |
tors | 1:e6e3af75f623 | 11 | t = 2.0; |
tors | 1:e6e3af75f623 | 12 | wait(t); |
tors | 0:c26cdf21261a | 13 | LR = 1; |
tors | 1:e6e3af75f623 | 14 | wait(t); |
tors | 0:c26cdf21261a | 15 | LR = 0; |
tors | 0:c26cdf21261a | 16 | } |
tors | 1:e6e3af75f623 | 17 | else |
tors | 1:e6e3af75f623 | 18 | { |
tors | 1:e6e3af75f623 | 19 | if(t >= 0.2) |
tors | 1:e6e3af75f623 | 20 | { |
tors | 1:e6e3af75f623 | 21 | t -= 0.2; |
tors | 0:c26cdf21261a | 22 | } |
tors | 1:e6e3af75f623 | 23 | wait(t); |
tors | 1:e6e3af75f623 | 24 | LR = 1; |
tors | 1:e6e3af75f623 | 25 | wait(0.2); |
tors | 1:e6e3af75f623 | 26 | LR = 0; |
tors | 0:c26cdf21261a | 27 | } |
tors | 0:c26cdf21261a | 28 | } |
tors | 0:c26cdf21261a | 29 | } |
tors | 1:e6e3af75f623 | 30 | |
tors | 1:e6e3af75f623 | 31 |