Random Number generators are something which is used to draw out a random number and use it for a specified purpose. The purpose may differ it might be lottery draw , competition or whatever it may be the above generator using 8051 will do a pretty good job also the complexity level of the program is very simple.
IC 74LS48:
The IC 74LS48 or 7448 is a simple BCD to 7 segment decoder which was used to reduce the usage of pins dedicated to the 7 segment display. It consists of 4 input pins namely 1,2,3,4 which is used to feed 4 bit data input to the IC. The fed 4 bit input binary data in turn decoded by the IC and output is obtained from the pins a, b ..... f which is connected to the corresponding pins of the 7 segment display. This will display the correct digit in the 7 segment display.
DESIGN:
In the above design i have used two 7448 IC to interface two 7 segments in a single port, this will save the pin usage from the microcontroller. You can also go for direct interfacing of a 7 segment with a dedicated port if you don't have 7448 IC in your possession.
Interrupt 0 feature of the Microcontroller was used here, therefore a simple push button was interfaced with the pin INT0 pin of the 8051 controller. Reset button was used with the pin 9 to reset the operation and start running the program from the beginning.
NUMBER GENERATION PROCESS:
- Initially the number keeps running from 0 to 99 in the display at high speed in a loop, so it will barely visible to human eye.
- Pressing the interrupt button fetches the random number and displays it in the 7 segment display.
- The the reset button should be pressed to initialize the program and counting again.
CODE:
This code was built using Keil Uvision 4
|
NOTE:
- Resistors for 7 segment are omitted for the simplicity of the schematic diagram, hook up a 470 ohm resistor to each pins connecting from 74LS48 to 7 segment pins.