Nov 13, 2005 #1 B buts101 Full Member level 3 Joined Apr 29, 2005 Messages 168 Helped 3 Reputation 6 Reaction score 2 Trophy points 1,298 Activity points 2,867 Random Number -->Random Number I need to generate random number on at89c51 microcontroller i.e. for the same input(+5) on same pin(P1.1)..i need to make random pin from P0.0 to P0.7, high. Please help me with the coding either in .asm or .C Thank you.
Random Number -->Random Number I need to generate random number on at89c51 microcontroller i.e. for the same input(+5) on same pin(P1.1)..i need to make random pin from P0.0 to P0.7, high. Please help me with the coding either in .asm or .C Thank you.
Nov 13, 2005 #2 leomecma Full Member level 5 Joined Jun 17, 2005 Messages 244 Helped 14 Reputation 28 Reaction score 1 Trophy points 1,298 Location Brasil Activity points 3,933 Re: Random Number Use RANDOM Function of C rand() limiting the value between 0 until 7 like it. #include <stdlib.h> int t; t = randon()%8; // Generate a random number between 0 -> 7 then you use ... P0 |= (1 << t) ; // This set the desired BIT Where P0 is P0OUT register ... it's just an example because I don't know this processor. leomecma
Re: Random Number Use RANDOM Function of C rand() limiting the value between 0 until 7 like it. #include <stdlib.h> int t; t = randon()%8; // Generate a random number between 0 -> 7 then you use ... P0 |= (1 << t) ; // This set the desired BIT Where P0 is P0OUT register ... it's just an example because I don't know this processor. leomecma
Nov 14, 2005 #3 syrax Full Member level 3 Joined Sep 15, 2005 Messages 183 Helped 11 Reputation 22 Reaction score 3 Trophy points 1,298 Activity points 2,620 Re: Random Number you can test some code using the timer
Nov 14, 2005 #4 B buts101 Full Member level 3 Joined Apr 29, 2005 Messages 168 Helped 3 Reputation 6 Reaction score 2 Trophy points 1,298 Activity points 2,867 Re: Random Number hello syrax... could u post timer coding in C...for getting the same above result (random pin high). Thank you.
Re: Random Number hello syrax... could u post timer coding in C...for getting the same above result (random pin high). Thank you.
Nov 16, 2005 #5 D ductrungvn Newbie level 3 Joined Oct 7, 2005 Messages 3 Helped 1 Reputation 2 Reaction score 1 Trophy points 1,283 Activity points 1,312 Re: Random Number Hi leomecma I don't know use C codes in using 8051 microcontroller so how to generate random number using code in asm??? Thank you.
Re: Random Number Hi leomecma I don't know use C codes in using 8051 microcontroller so how to generate random number using code in asm??? Thank you.