- 1 Random Number Generator using 8051 Microcontroller Circuit Diagram:
- 1.1 Random Number Generator using 8051 Circuit Design:
- 1.2 Random Number Generator using 8051 – Circuit Simulation Video:
- 1.3 How to Operate Random Number Generator Circuit using 8051:
- 1.4 Random Number Generator using 8051 Circuit Applications:
- 1.5 Random Number Generator using 8051 Project Output Video:
- 2 Download Code
- 3 Related Articles
This article explains you how to generate a random number using 8051 microcontroller. This project generates a random number in between 0 to 100 when push button is pressed. This project is simple and may not find any serious applications in embedded projects, this is just an illustration.
Random Number Generator using 8051 Circuit Principle:
Random number generator is a physical device which generates a number randomly in a certain limit when button is pressed. In this project LCD (liquid crystal display) displays the number randomly when push button (which is connected P1.1) is pressed. In this the counter is incremented from 0 to 99 with a high speed. If you press the button then LCD displays the current count value. As the count is incrementing with high speed it selects a random number when button is pressed.
Related Post: 8 Channel Quiz Buzzer Circuit using 8051 Microcontroller
Random Number Generator using 8051 Microcontroller Circuit Diagram:
- at89c51 microcontroller
- programming board
- Programming cable
- DC battery or 12V, 1A adaptor
- 16*2 alphanumeric LCD
- 2 ceramic capacitors – 33pF
- 12 MHz crystal
- push button
- Electrolytic capacitor – 10uF, 16V
- Resistor (1/4 watt) – 10k
- Pot – 10k
- 5V DC power supply circuit
- Single pin connecting wires
- slide switch
Random Number Generator using 8051 Circuit Design:
The circuit is uses 8051 microcontroller, 16*2 alphanumeric LCD, push button and few passive components. The main component in this circuit is at89c51 controller. In the above circuit push button is connected to P1.1. LCD data pins are connected PORT2 of the microcontroller and control pins RS, RW, En are connected to P3.0, P3.1 and P3.2 respectively. Here the LCD is connected in 8 bit mode that is why we need to use all the data pins of LCD. Resistor R4 and capacitor C5 provides the reset circuit to the 8051 microcontroller. Capacitors C3, C4 along with 12 MHz crystal used to provide the frequency to the 8051 microcontroller. Here the pot RV1 which is connected to the 1, 2 and 3 pins of LCD is used to control the contrast of LCD. By adjusting the resistance of pot we can vary the contrast or brightness. If you want to reduce the data lines of LCD you can use 4 bit mode.
In this program even if you want to extend the upper limit of random number generator you can by making little changes in program. As we are using LCD it is possible to extend the upper limit of random number generator, whereas it in not possible to extend the upper limit if you use 2 seven segment displays.
Also read the post – Electronic Dice using LEDs
Now let us see how to write a program for Random number generator using 8051 microcontroller. Initially take a count variable of type integer and initialize the LCD in 8 bit mode. Now take an infinite while loop to repeat the program forever. Within the WHILE loop take FOR loop with the condition I <100 to increment the count up to 99. If you want extend the upper limit of random number generator change the condition in for loop. Within for loop check weather the button is pressed or not. If pressed then display the current count value on LCD.
Random Number Generator using 8051 – Circuit Simulation Video:
How to Operate Random Number Generator Circuit using 8051:
- Firstly write the program for Random number generator in keil software and generate the hex file.
- Now burn this hex file to the 8051 microcontroller with the help of flash magic software.
- Give the connections as per the circuit diagram
- Make sure that the power supply circuit output voltage is 5V DC.
- Now switch on the circuit supply
- You can observe “Random no. gen” string on LCD.
- Press the push button, now you can see a random number on LCD. Again if you press the button it will show another random number in between 0 to 100.
- Switch off the circuit supply.
Random Number Generator using 8051 Circuit Applications:
- This project is used in the applications where we need to generate Random number
- Used in noise generators
- Project is used as an alternative for the traditional dice while playing the games like monopoly, snake ladder.
Random Number Generator using 8051 Project Output Video:
If you are interested to get code, kindly take some time and answer following questions in the comment section, so that we will send you the code.
- Why you need this project code?
- Are you trying to make the same project or different one?
- Give us more details about your project.