![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Beganovic Benjamin Mustafic Faruk
main.cpp@0:34edea07dc58, 2014-03-10 (annotated)
- Committer:
- tim008
- Date:
- Mon Mar 10 09:45:17 2014 +0000
- Revision:
- 0:34edea07dc58
lab2_grupa2_tim8
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tim008 | 0:34edea07dc58 | 1 | #include <cmath> |
tim008 | 0:34edea07dc58 | 2 | |
tim008 | 0:34edea07dc58 | 3 | #include "mbed.h" |
tim008 | 0:34edea07dc58 | 4 | |
tim008 | 0:34edea07dc58 | 5 | #define WAIT_TIME 1 |
tim008 | 0:34edea07dc58 | 6 | #define MAX_COUNT 255 |
tim008 | 0:34edea07dc58 | 7 | |
tim008 | 0:34edea07dc58 | 8 | |
tim008 | 0:34edea07dc58 | 9 | int main() { |
tim008 | 0:34edea07dc58 | 10 | BusOut my_ledice(dp23, dp24, dp25, dp26, |
tim008 | 0:34edea07dc58 | 11 | dp27, dp5, dp6, dp28); |
tim008 | 0:34edea07dc58 | 12 | my_ledice = 0; |
tim008 | 0:34edea07dc58 | 13 | |
tim008 | 0:34edea07dc58 | 14 | DigitalOut enable_signal(dp14); |
tim008 | 0:34edea07dc58 | 15 | enable_signal = 0; |
tim008 | 0:34edea07dc58 | 16 | |
tim008 | 0:34edea07dc58 | 17 | while(true) { |
tim008 | 0:34edea07dc58 | 18 | if(DigitalIn(dp1)) |
tim008 | 0:34edea07dc58 | 19 | my_ledice = |
tim008 | 0:34edea07dc58 | 20 | (my_ledice == 0) ? MAX_COUNT : ((my_ledice - 1) % MAX_COUNT); |
tim008 | 0:34edea07dc58 | 21 | else |
tim008 | 0:34edea07dc58 | 22 | my_ledice = ((my_ledice + 1) % MAX_COUNT); |
tim008 | 0:34edea07dc58 | 23 | |
tim008 | 0:34edea07dc58 | 24 | wait(WAIT_TIME); |
tim008 | 0:34edea07dc58 | 25 | } |
tim008 | 0:34edea07dc58 | 26 | |
tim008 | 0:34edea07dc58 | 27 | return 0; // redundant |
tim008 | 0:34edea07dc58 | 28 | } |