This program will give you some numbers for you to play the Euro Millions game. It needs the USB / serial connection and a terminal application on the PC side. Tested on KL25Z Good Luck

Dependencies:   mbed

main.cpp

Committer:
lmsousa
Date:
2015-05-08
Revision:
0:4ade2e491919
Child:
1:5179636dca4b

File content as of revision 0:4ade2e491919:

#include "mbed.h"
#define totalN 50   // Valid numbers
#define totalS 11   // Valid Stars
#define guessN 5    // How many numbers to guess
#define guessS 2    // How many stars to guess

DigitalOut rled(LED_RED);
DigitalOut gled(LED_GREEN);
Serial pc(USBTX, USBRX);

int play=1;
int n=0;
char opcao='N';
int main()
{
    rled=1;
    gled=1;
    pc.baud(9600);
    do {
        pc.printf("%c[2J",27);
        pc.printf(" ---------------------------------\r\n");
        pc.printf("|           EUROMILHOES           |\r\n");
        pc.printf("|         Luis Sousa 2015         |\r\n");
        pc.printf(" ---------------------------------\r\n\n\n");
        pc.printf("Previsoes para proximo sorteio: \r\n\n");
        pc.printf("\r\n---------------------------------\r\n");
        pc.printf("Numeros: ");
        for (n=1; n<(guessN+1); n++) {
            pc.printf("%i  ",rand()%totalN);
            rled=!rled;
            wait (1.2);
        }
        rled=1;
        pc.printf("\r\n---------------------------------\r\n");
        pc.printf("Estrelas: ");
        for (n=1; n<(guessS+1); n++) {
            pc.printf("%i  ",rand()%totalS);
            gled=!gled;
            wait (1.2);
        }
        pc.printf("\r\n---------------------------------\r\n\n");
        pc.printf("Novo Sorteio? (S/N) \r\n");
        opcao=pc.getc();
//      scanf(" %c", &opcao);
//      opcao = getchar();    */
        if((opcao =='S')||(opcao =='s')) play=1;
        else {
            play=0;
//          clrscr();
            pc.printf("Boa Sorte! \r\n\n");
        }
    } while (play);
}