part2

Dependencies:   mbed

main.cpp

Committer:
jaredwil
Date:
2015-03-03
Revision:
0:49b55c5b7bef

File content as of revision 0:49b55c5b7bef:

#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;
        }
         
  
    }
}