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
Diff: main.cpp
- Revision:
- 0:4ade2e491919
- Child:
- 1:5179636dca4b
diff -r 000000000000 -r 4ade2e491919 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri May 08 12:14:32 2015 +0000 @@ -0,0 +1,53 @@ +#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); +}