Here is a working version of your code. It’s pausing random intervals between turning on and then turning off the leds.
[code]LED1 con P12 ; Red LED
LED2 con P13 ; Green LED
LED3 con P14 ; Yellow LED
result VAR Word
smaller var byte
result = 500
Main
result = RANDOM result
smaller = result / 256
; serout s_out,i38400,"result= ", dec result, "smaller= ", dec smaller, 13]
gosub TurnLEDsOn
gosub TurnLEDsOff
goto main
End
TurnLEDsOn ; LED on subroutine
pause result
high LED1
pause result
high LED2
pause result
high LED3
return
TurnLedsOff ; LED off subroutine
Low LED1
pause result
Low LED2
pause result
Low LED3
pause result
return[/code]
Here is another way to do it. Random, but sequential…
[code]LED1 con P12 ; Red LED
LED2 con P13 ; Green LED
LED3 con P14 ; Yellow LED
result VAR Word
smaller var byte
smallest var bit
temp var byte
result = 500
for temp = 12 to 14
low temp
next
Main
; serout s_out,i38400,"result= ", dec result, "smaller= ", dec smaller, "smallest= ", dec smallest, 13]
for temp = 12 to 14
gosub getrandom
toggle temp
pause smaller
next
goto main
getrandom
result = RANDOM result ; result = (0 - 65535)
smaller = result / 256 ; smaller = (0 - 255)
smallest = smaller//2 ; temp = (0 - 1) 0 = even, 1 = odd
return[/code]
However if you want to have them blinking at random…
[code]LED1 con P12 ; Red LED
LED2 con P13 ; Green LED
LED3 con P14 ; Yellow LED
result VAR Word
smaller var byte
smallest var bit
temp var byte
result = 500
for temp = 12 to 14
low temp
next
Main
for temp = 12 to 14
gosub getrandom
if smallest then
toggle temp
endif
pause smaller
next
goto main
getrandom
result = RANDOM result ; result = (0 - 65535)
smaller = result / 256 ; smaller = (0 - 255)
smallest = smaller//2 ; temp = (0 - 1) 0 = even, 1 = odd
return[/code]