Hi All,
I'm just starting to tinker with the Random command to light up 4 LEDS in any combination from $0h to $Fh.
As i'm only using 4 bits to drive the LEDs, the random word seems to spend a lot of time generating big numbers larger than $Fh, so my LEDs are often in the OFF state.
Can the random command be told to only generate numbers within a given range? or would i check if the number is greater than $Fh and then divide it down until it is equal (or less than) $Fh ?
I recently thought about using a lookup/lookdown array for my 16 values, but of course the large random word values prevent looking for the correct number in my lookup/lookdown selection.
I'm not sure what my options are now for something that seemed like an easy idea when i first began trying some code with the random command, now i've stuck myself in a hole lol.
with thanks in advance...
I'm just starting to tinker with the Random command to light up 4 LEDS in any combination from $0h to $Fh.
As i'm only using 4 bits to drive the LEDs, the random word seems to spend a lot of time generating big numbers larger than $Fh, so my LEDs are often in the OFF state.
Can the random command be told to only generate numbers within a given range? or would i check if the number is greater than $Fh and then divide it down until it is equal (or less than) $Fh ?
I recently thought about using a lookup/lookdown array for my 16 values, but of course the large random word values prevent looking for the correct number in my lookup/lookdown selection.
I'm not sure what my options are now for something that seemed like an easy idea when i first began trying some code with the random command, now i've stuck myself in a hole lol.
with thanks in advance...