Page 202 - ARM Based Microcontroller Projects Using MBED
P. 202
188 8. INTERMEDIATE LEVEL PROJECTS
8.18 PROJECT 15—EURO MILLIONAIRE LOTTERY NUMBERS
8.18.1 Description
This is a Euro Millionaire Lottery Numbers project. In the Euro Millions Lottery, there are
two sections: the Lottery Numbers section and the Lucky Stars section where the user is re-
quired to select numbers from each section. In the Lottery Numbers section, there are num-
bers from 1 to 50 and the user is required to select only 5 numbers. In the Lucky Stars section,
there are numbers from 1 to 12 and the user is required to select only 2 numbers. Therefore, 7
numbers have to be selected in total.
In this project, five unique random Lottery Numbers are generated between 1 and 50 in-
clusive, and also two unique random Lucky Stars numbers are generated between 1 and 12 in-
clusive. Clicking the User button generates a set of numbers for the game and these numbers
are displayed on the PC screen.
8.18.2 Aim
The aim of this project is to show how the various serial communication functions can be
used in a program to generate the Euro Millionaire lottery numbers.
8.18.3 The PDL
Fig. 8.51 shows the program PDL.
8.18.4 Program Listing
The program listing (program: Lottery) is shown in Fig. 8.52. At the beginning of the pro-
gram, two arrays named LotteryNumbers and LuckyStarNumbers are declared to store the
BEGIN/MAIN
DO FOREVER
Wait until button is pressed
Clear the screen and home the cursor
CALL Generate (5) to generate Lottery numbers
CALL Generate (2) to generate Lucky Star numbers
Display the generated Lottery numbers
Display the generated Luck Star numbers
END/MAIN
BEGIN/Generate (N)
Generate N unique random numbers
END/Generate
FIG. 8.51 Program PDL.