Everytime you use Random, you in effect seed a new value in the word variable RandomValue. You only want the bottom two bits (to give you your four possible values) so extract them... Use those bits to illuminate your LED's... simple...
Code:
LEDA var PortB.0
LEDB var PortB.1
LEDC var PortB.2
LEDD var PortB.3
RandomValue var WORD
LEDValue var BYTE
Start:
Low LEDA
Low LEDB
Low LEDC
Low LEDD
Random RandomValue
LEDValue=RandomValue & $03
If LEDValue=0 then High LEDA
If LEDValue=1 then High LEDB
If LEDValue=2 then High LEDC
If LEDValue=3 then High LEDD
Pause 1000
Goto Start
This will give you one-of-four Random selection forever. I haven't got PBC but I'm sure you could convert it simply...
Bookmarks