I've tried to randomize 20 LEDs hooked up as shown in the attachment with the following code:
(Sorry, I've had to retype it. Long story.)
Code:
clear
define osc4
ansel=0
comcon0=7
adcon0=0
delay var word
myword var word
mybyte var byte
previous_random var byte
gpiostate var byte
tristate var byte
delay = 250
main:
random myword
mybyte = (myword//20)
if previous_random = mybyte then goto main
gosub high_led
pause delay
gpio = %000000
pause delay
previous_random= mybyte
goto main
high led:
lookup mybyte,[%000001, etc for 20 LEDs], gpiostate
gpio = gpiostate
lookup mybyte,[%111100, etc for 20 LEDs], tristate
trisio = tristate
return
The problem I'm having is two fold.
First, LED0 never lights. I've watched it for a about 3 minutes several times and that first LED never lights. Any ideas why?
Secondly, although I implement the previous_random scheme shown previously in the thread, I often get an LED that will light repeatedly before moving on. Any ideas why?
As always, most of your thoughts are appreciated.
Bookmarks