![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Stoer
main.cpp@6:311215b698bc, 2014-10-10 (annotated)
- Committer:
- jessekaiser
- Date:
- Fri Oct 10 09:23:03 2014 +0000
- Revision:
- 6:311215b698bc
- Parent:
- 5:a51101bc8ab7
- Child:
- 7:a4627dcedfcc
Stoer;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jessekaiser | 0:702da75f76db | 1 | #include "mbed.h" |
jessekaiser | 6:311215b698bc | 2 | #include "MODSERIAL.h" |
jessekaiser | 1:0a58287f3b6b | 3 | |
jessekaiser | 0:702da75f76db | 4 | Serial pc(USBTX, USBRX); // tx, rx |
jessekaiser | 1:0a58287f3b6b | 5 | DigitalOut myled1(LED_RED); |
jessekaiser | 1:0a58287f3b6b | 6 | DigitalOut myled2(LED_GREEN); |
jessekaiser | 6:311215b698bc | 7 | DigitalOut myled3(LED_BLUE); |
jessekaiser | 0:702da75f76db | 8 | |
jessekaiser | 0:702da75f76db | 9 | |
jessekaiser | 0:702da75f76db | 10 | int main() |
jessekaiser | 0:702da75f76db | 11 | { |
jessekaiser | 4:bfaeee1cc449 | 12 | char c = '0'; |
jessekaiser | 4:bfaeee1cc449 | 13 | while(1) { |
jessekaiser | 5:a51101bc8ab7 | 14 | pc.printf("Het programma blijft knipperen totdat er op '1' wordt gedrukt.\n"); |
jessekaiser | 4:bfaeee1cc449 | 15 | do { |
jessekaiser | 3:a0dd633faf72 | 16 | myled1 = 1; |
jessekaiser | 3:a0dd633faf72 | 17 | myled2 = 1; |
jessekaiser | 6:311215b698bc | 18 | myled3 = 1; |
jessekaiser | 6:311215b698bc | 19 | wait(1); |
jessekaiser | 2:ea19e2e4a070 | 20 | myled1 = 1; |
jessekaiser | 2:ea19e2e4a070 | 21 | myled2 = 0; |
jessekaiser | 6:311215b698bc | 22 | myled3 = 1; |
jessekaiser | 4:bfaeee1cc449 | 23 | wait(1); |
jessekaiser | 6:311215b698bc | 24 | if(pc.readable()) { |
jessekaiser | 4:bfaeee1cc449 | 25 | c = pc.getc(); |
jessekaiser | 4:bfaeee1cc449 | 26 | } |
jessekaiser | 4:bfaeee1cc449 | 27 | } while(c != '1'); |
jessekaiser | 4:bfaeee1cc449 | 28 | //c = pc.getc(); |
jessekaiser | 4:bfaeee1cc449 | 29 | while((c == '1')) { |
jessekaiser | 1:0a58287f3b6b | 30 | myled1 = 1; |
jessekaiser | 1:0a58287f3b6b | 31 | myled2 = 1; |
jessekaiser | 6:311215b698bc | 32 | myled3 = 1; |
jessekaiser | 3:a0dd633faf72 | 33 | wait(1); |
jessekaiser | 3:a0dd633faf72 | 34 | myled1 = 0; |
jessekaiser | 3:a0dd633faf72 | 35 | myled2 = 1; |
jessekaiser | 6:311215b698bc | 36 | myled3 = 1; |
jessekaiser | 4:bfaeee1cc449 | 37 | wait(1); |
jessekaiser | 1:0a58287f3b6b | 38 | } |
jessekaiser | 6:311215b698bc | 39 | |
jessekaiser | 6:311215b698bc | 40 | while((c == '2')){ |
jessekaiser | 6:311215b698bc | 41 | myled1 = 1; |
jessekaiser | 6:311215b698bc | 42 | myled2 = 1; |
jessekaiser | 6:311215b698bc | 43 | myled3 = 1; |
jessekaiser | 6:311215b698bc | 44 | wait(1); |
jessekaiser | 6:311215b698bc | 45 | myled1 = 1; |
jessekaiser | 6:311215b698bc | 46 | myled2 = 1; |
jessekaiser | 6:311215b698bc | 47 | myled3 = 0; |
jessekaiser | 6:311215b698bc | 48 | wait(1); |
jessekaiser | 6:311215b698bc | 49 | } |
jessekaiser | 6:311215b698bc | 50 | |
jessekaiser | 6:311215b698bc | 51 | |
jessekaiser | 4:bfaeee1cc449 | 52 | } |
jessekaiser | 4:bfaeee1cc449 | 53 | } |