Jinx, looks good, may not need it now, but will probably try it anyways. Learing is good, it'll give me practice. I'll try a hardware & software solution, and see which I like better. Thanks, dave On 8/12/02 5:54 PM, "Jinx" wrote: >> I=B9m doing led dies >=20 > As someone else suggested a fast-running clock will give you > random output on the dice. I've seen a couple of electronic > dice projects in magazines that do it this way. The dice are > driven 1 - 6 at high speed (no micro, just an oscillator) and it's > purely chance what number is showing when you push a button >=20 > However, you did also ask about external input. I've had to do this > very recently to generate large random numbers and used white > noise >=20 > http://home.clear.net.nz/pages/joecolquitt/white_noise.html >=20 > This little snippet of code may not make a lot of sense out of context > but what it basically does is to read the timer low byte after a random > delay (caused by noise transitions on a port pin). The timer low byte > read after this delay then becomes the random number used in the > rest of the code. It appears so far to produce unpredictable randomness >=20 > I'm pretty sure you don't need to go to these lengths as you're dealing > with a restricted range of numbers >=20 > ;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >=20 > rndlo call noise > movf tmr1l,w ;get timer low byte after random delay > movwf lo >=20 > btfss high_eqlm ;test addlow if hi=3Dcnt2 > goto rnd_th ;else keep it >=20 > movlw 0x01 ;comparison for range limit > addwf cnt1,w > subwf lo,w > btfsc carry > goto rndlo ;re-generate until lo < cnt1+1 >=20 > ....... rest of code > ;----------- >=20 > noise movf tmr1l,w ;loop anywhere from 0x08 to 0x17 times > andlw 0x0f > addlw 0x08 > movwf index > t_rnd btfss noise ;count noise L > H > L transitions > goto $-1 > nop > btfsc noise > goto $-1 > decfsz index,f > goto t_rnd > return >=20 > -- > http://www.piclist.com hint: The PICList is archived three different > ways. See http://www.piclist.com/#archives for details. >=20 >=20 >=20 -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.