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