![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
part2
Dependencies: mbed
Diff: main.cpp
- Revision:
- 0:49b55c5b7bef
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Mar 03 19:24:31 2015 +0000 @@ -0,0 +1,48 @@ +#include "mbed.h" + +BusIn joy(p15,p12,p13,p16); + +BusOut leds(LED1,LED2,LED3,LED4); + +Serial pc(USBTX, USBRX); + +int main() +{ + int one[4] = {0x1, 0x2, 0x4, 0x8}; + int two[6] = {0x3, 0x5, 0x9, 0x6, 0xA,0xC}; + int three[4] = {0x7, 0xB, 0xE, 0xD}; + srand(time(NULL)); + int a; + while(1) { + leds = 0x0; + + switch(joy) { + case 0x1: + leds = 0xF; + break; + case 0x2: + a = (rand()%4); + leds = three[a]; + while(joy == 0x2){ + //WAIT + } + break; + case 0x4: + a = (rand()%6); + leds = two[a]; + while(joy == 0x4){ + //WAIT + } + break; + case 0x8: + a = (rand()%4); + leds = one[a]; + while(joy == 0x8){ + //WAIT + } + break; + } + + + } +} \ No newline at end of file