Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Generating a random number in pic16f877a

Status
Not open for further replies.

thomasscms

Newbie level 1
Newbie level 1
Joined
Jul 21, 2013
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
6
hi

for a project, i have to generate a random number between 0 and 9, and display it on seven segment display using pic16f877a. i tried using

rn = rand()%10;

but only 0x0008 is coming out..
can sm1 suggest a solution?
 

One way is to have a button that the user presses to make a random number appear (or change it). In the main loop of your software add 1 to memory location (and wrap 9+1 to 0) so you have a counter that changes thousands of times a second. When the user presses the button copy the current value to the display. The time between each press of the button will always be different so the number displayed will be random.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top