tim007 tim007
/
LV1_G1_Tim007_Zad2
Enil Pajić Aida Pločo
main.cpp@0:5fd44252399a, 2014-03-03 (annotated)
- Committer:
- tim007
- Date:
- Mon Mar 03 07:37:49 2014 +0000
- Revision:
- 0:5fd44252399a
LV1_G1_Tim007_Zad2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tim007 | 0:5fd44252399a | 1 | #include "mbed.h" |
tim007 | 0:5fd44252399a | 2 | |
tim007 | 0:5fd44252399a | 3 | DigitalOut myled(LED2); |
tim007 | 0:5fd44252399a | 4 | |
tim007 | 0:5fd44252399a | 5 | int main() { |
tim007 | 0:5fd44252399a | 6 | while(1) { |
tim007 | 0:5fd44252399a | 7 | myled = 0; |
tim007 | 0:5fd44252399a | 8 | wait(1); |
tim007 | 0:5fd44252399a | 9 | myled = 1; |
tim007 | 0:5fd44252399a | 10 | wait(1); |
tim007 | 0:5fd44252399a | 11 | const double e = 0.9/30.0; |
tim007 | 0:5fd44252399a | 12 | double f = 1 + e; // 1.03 |
tim007 | 0:5fd44252399a | 13 | double h = 1 - e; // 1 - 0.03 |
tim007 | 0:5fd44252399a | 14 | for (int a = 0; a < 30; ++a) |
tim007 | 0:5fd44252399a | 15 | { |
tim007 | 0:5fd44252399a | 16 | myled = 0; // Ukljucena |
tim007 | 0:5fd44252399a | 17 | wait (f); // za 1.03 pa 1.06, 1.09 ... pa 1.9 |
tim007 | 0:5fd44252399a | 18 | f += e; |
tim007 | 0:5fd44252399a | 19 | myled = 1; // Iskljucena |
tim007 | 0:5fd44252399a | 20 | wait (h); // za 0.97, pa 0.94 ... pa 0.1 |
tim007 | 0:5fd44252399a | 21 | h -= e; |
tim007 | 0:5fd44252399a | 22 | } |
tim007 | 0:5fd44252399a | 23 | f = 1 - e; |
tim007 | 0:5fd44252399a | 24 | h = 1 + e; |
tim007 | 0:5fd44252399a | 25 | for (int a = 0; a < 60; ++a) |
tim007 | 0:5fd44252399a | 26 | { |
tim007 | 0:5fd44252399a | 27 | myled = 0; |
tim007 | 0:5fd44252399a | 28 | wait (f); |
tim007 | 0:5fd44252399a | 29 | f -= e; |
tim007 | 0:5fd44252399a | 30 | myled = 1; |
tim007 | 0:5fd44252399a | 31 | wait (h); |
tim007 | 0:5fd44252399a | 32 | h += e; |
tim007 | 0:5fd44252399a | 33 | |
tim007 | 0:5fd44252399a | 34 | } |
tim007 | 0:5fd44252399a | 35 | } |
tim007 | 0:5fd44252399a | 36 | } |