Banner1

PICLotto the random Lotto and Thunderball selection device

Schematic Pictures Download Instructions Order a programmed PIC Hit Counter  
For a long time now, I have been interested in programming PICs. They are Programmable Integrated Circuits. The amazing thing about these little beauties, is that they are a computer system all in one chip. They usually have a couple or more ports...(connexions into, and out of the chip) some have a USB interface built in, and others have a serial port in them. Most these days have Flash Memory, so you can program them to do something, and then at a later date, erase them and insert a different program. To do this you use a PIC programmer.
One of the PICS I like using comes from MicroChip, and is capable of programming itself!! I don't mean it makes it's own program, I mean you just load a great piece of software called a bootloader, and then the chip stays in it's destination gadget, and you can update it's program through a hardware serial port. A very clever guy called Myke Predko has developed a BASIC language version for this particular PIC, and to program it, you connect a PC serial port running Hyperterminal, and then it behaves like the old console driven Basic interpreters.. Awesome.
     
The particular PIC I'm referring to is the MicroChip 16F877A
     
I have a great belief in randomness, and if you really want to win a lottery, you have to accept that the balls are selected randomly, therefore no method, or formula is ever going to make your selection win. A similarly random selection has at best equal odds. I set about building a device to give me a series of numbers I could use for Lotto and Thunderball. About the same time I was looking at the 16F877A, I was also looking at HD44870 LCD screens. These devices come in various guises:- different colours and different sizes..2x16 2x20 4x16 4x20 2x40 etc.
I had a feeling these were a bit over the top considering I only wanted 6 numbers displayed. I recently saw some 2x8 versions on Ebay, and snapped a few up. so now I had the parts I needed, how was I going to make this gadget work.
     
Most programmers know there is no computer program capable of providing a genuine random number...they follow instructions and all the time the instructions don't change, the sequence won't either so a better method is needed. I decided to let the user contribute to the randomness. When I'm ready to calculate a number, I light an LED. Once that LED is lit, the program is running through it's sequence and only looking at numbers between 1 and 49 in the case of Lotto, and 1 and 34 in Thunderball. The resulting number is only chosen when the user operates a pushbutton in response to the LED lighting. The time interval between the LED lighting, and the button being pressed is probably a lot more random than computer generated numbers.
     
For the programmers among us, I found debouncing the keypresses a big challenge, until I got my head around checking if it is pushed, ok now check to see it is not. Only then has a valid press been detected.
     
Here is the circuit diagram....nothing too taxing here.
List of parts:-
1 x development board
1 x 40 pin Dil Socket
1 x 9v Battery clip
1 x 9v Battery
1 x 4Mhz Resonator, or crystal with 2 x 180pf capacitors
1 x 7805 5v Regulator
1 x PIC 16F877A
1 x 10uF 20v Capacitor
1 x 680 ohm 0.25 watt resistor
2 x 10k ohm 0.25 watt resistor
1 x 10k variable resistor
1 x LCD 8x2 HD44870 compatible
1 x 5mm LED
2 x Push switches
NB. I can supply a ready programmed 16F877A for 9.99 to order. Pse email me if you would like me to send you the PIC pre-programmed. Paul Bartlett
 
Here are some photos of my development board:-
     
The program running in the PIC can be downloaded here:- PICLotto.hex
   
Instructions for Use:
Lotto ThunderBall
This is a draw of 6 numbers ranging between 1 - 49 This is a draw of 5 numbers from 1 - 34, and 1 number from 1 - 14
Action Screen LED Action Screen LED
Apply power (9v) and switch on. Off Apply power (9v) and switch on. Off
Wait a couple of seconds. Off Wait a couple of seconds. Off
Wait a couple of seconds. Off Wait a couple of seconds. Off
Wait a couple of seconds. Off Wait a couple of seconds. Off
Wait a couple of seconds. Off Wait a couple of seconds. Off
Press button 1 for Lotto,or Press button 2 for Thunderball..let's press 1 for Lotto. Off Press button 1 for Lotto,or Press button 2 for Thunderball..let's press 2 for Thunderball. Off
Wait a couple of seconds. Off Wait a couple of seconds. Off
Wait for LED to Light. On Wait for LED to Light. On
Press button 1. Off Press button 1. Off
Wait for LED to Light. On Wait for LED to Light. On
Press button 1. Off Press button 1. Off
Wait for LED to Light. On Wait for LED to Light. On
Press button 1. Off Press button 1. Off
Wait for LED to Light. On Wait for LED to Light. On
Press button 1. Off Press button 1. Off
Wait for LED to Light. On Wait for LED to Light. On
Press button 1. Off Press button 1. Off
Wait for LED to Light. On Wait for LED to Light. On
Press button 1. Off Press button 1. Off
You should notice that on this last button press, not only has our sixth number appeared, All the numbers are now sorted lowest - highest. Wait a couple of seconds.

Off