![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
part2
Dependencies: mbed
main.cpp@0:49b55c5b7bef, 2015-03-03 (annotated)
- Committer:
- jaredwil
- Date:
- Tue Mar 03 19:24:31 2015 +0000
- Revision:
- 0:49b55c5b7bef
part2;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jaredwil | 0:49b55c5b7bef | 1 | #include "mbed.h" |
jaredwil | 0:49b55c5b7bef | 2 | |
jaredwil | 0:49b55c5b7bef | 3 | BusIn joy(p15,p12,p13,p16); |
jaredwil | 0:49b55c5b7bef | 4 | |
jaredwil | 0:49b55c5b7bef | 5 | BusOut leds(LED1,LED2,LED3,LED4); |
jaredwil | 0:49b55c5b7bef | 6 | |
jaredwil | 0:49b55c5b7bef | 7 | Serial pc(USBTX, USBRX); |
jaredwil | 0:49b55c5b7bef | 8 | |
jaredwil | 0:49b55c5b7bef | 9 | int main() |
jaredwil | 0:49b55c5b7bef | 10 | { |
jaredwil | 0:49b55c5b7bef | 11 | int one[4] = {0x1, 0x2, 0x4, 0x8}; |
jaredwil | 0:49b55c5b7bef | 12 | int two[6] = {0x3, 0x5, 0x9, 0x6, 0xA,0xC}; |
jaredwil | 0:49b55c5b7bef | 13 | int three[4] = {0x7, 0xB, 0xE, 0xD}; |
jaredwil | 0:49b55c5b7bef | 14 | srand(time(NULL)); |
jaredwil | 0:49b55c5b7bef | 15 | int a; |
jaredwil | 0:49b55c5b7bef | 16 | while(1) { |
jaredwil | 0:49b55c5b7bef | 17 | leds = 0x0; |
jaredwil | 0:49b55c5b7bef | 18 | |
jaredwil | 0:49b55c5b7bef | 19 | switch(joy) { |
jaredwil | 0:49b55c5b7bef | 20 | case 0x1: |
jaredwil | 0:49b55c5b7bef | 21 | leds = 0xF; |
jaredwil | 0:49b55c5b7bef | 22 | break; |
jaredwil | 0:49b55c5b7bef | 23 | case 0x2: |
jaredwil | 0:49b55c5b7bef | 24 | a = (rand()%4); |
jaredwil | 0:49b55c5b7bef | 25 | leds = three[a]; |
jaredwil | 0:49b55c5b7bef | 26 | while(joy == 0x2){ |
jaredwil | 0:49b55c5b7bef | 27 | //WAIT |
jaredwil | 0:49b55c5b7bef | 28 | } |
jaredwil | 0:49b55c5b7bef | 29 | break; |
jaredwil | 0:49b55c5b7bef | 30 | case 0x4: |
jaredwil | 0:49b55c5b7bef | 31 | a = (rand()%6); |
jaredwil | 0:49b55c5b7bef | 32 | leds = two[a]; |
jaredwil | 0:49b55c5b7bef | 33 | while(joy == 0x4){ |
jaredwil | 0:49b55c5b7bef | 34 | //WAIT |
jaredwil | 0:49b55c5b7bef | 35 | } |
jaredwil | 0:49b55c5b7bef | 36 | break; |
jaredwil | 0:49b55c5b7bef | 37 | case 0x8: |
jaredwil | 0:49b55c5b7bef | 38 | a = (rand()%4); |
jaredwil | 0:49b55c5b7bef | 39 | leds = one[a]; |
jaredwil | 0:49b55c5b7bef | 40 | while(joy == 0x8){ |
jaredwil | 0:49b55c5b7bef | 41 | //WAIT |
jaredwil | 0:49b55c5b7bef | 42 | } |
jaredwil | 0:49b55c5b7bef | 43 | break; |
jaredwil | 0:49b55c5b7bef | 44 | } |
jaredwil | 0:49b55c5b7bef | 45 | |
jaredwil | 0:49b55c5b7bef | 46 | |
jaredwil | 0:49b55c5b7bef | 47 | } |
jaredwil | 0:49b55c5b7bef | 48 | } |