Uses Maxim 7219 for random LED twinkle:
' Twinkle makes the LED's twinkle on and off at random
at .1 second
' increments. At least 2 will be on at the same time
for this routine.
Twinkle:
'GOSUB Clear
Again:
RANDOM Number ' Generate a random number for section
number.
IF Number.NIB0 > 8 THEN Again ' Try again if number
is greater than 8.
SHIFTOUT DATAIN,CLK,MSBFIRST,[Number] ' Send section
position.
Again1:
RANDOM Number1 ' Generate a random number for LED.
IF Number1 > 255 THEN Again1 ' Try again if number
is greater than 128.
SHIFTOUT DATAIN,CLK,MSBFIRST,[Number1] ' Send out
data to chip.
PULSOUT Load,1 ' Send pulse to load LED's.
PAUSE 10 ' Pause for .01 seconds.
GOTO Main
|
Uses Maxim 7219 for
LED chase sequence:
The lookup table needs to be changed depending on
what LED is to be selected to get the chase sequence.
Each number corresponds to the address. The duplicates
on the first Lookup match the 0's on the second Lookup
because the 0 turns off the LED that was just shown.
Hence, the chase sequence.
' Turns on one LED at a time in sequence.
Chase:
' 1
FOR Stepin = 1 TO 6 ' Increment for each LED digit.
GOSUB Update ' Check to see if Mode change or Brightness change.
LOOKUP Stepin-1,[6,6,4,4,3,3],Dataout ' Each Digit is twice to
match the 0's which clear it below.
SHIFTOUT DATAIN,CLK,MSBFIRST,[Dataout\4] ' Send section position.
LOOKUP Stepin-1,[64,0,8,0,4,0],Dataout ' Put next LED into output
word. 0's clear it.
SHIFTOUT DATAIN,CLK,MSBFIRST,[Dataout\8] ' Send out data to chip.
PULSOUT Load,1 ' Send pulse to load LED's.
'PAUSE 10 ' Pause time.
NEXT |
Generates a VERY random number
to output using the Maxim 7219:
This code actually has two different Lookup tables.
A random number is generated every other pulse.
Display: ' Send out data to displays.
RANDOM Number ' Generate random number
FOR Index = 1 TO 6 ' Work from segment 1 up to 6.
'DEBUG DEC ? Number.NIB0
SHIFTOUT DATAIN,CLK,MSBFIRST,[Index\4] ' Send out
Segement.
IF Odd = 0 THEN Skipit
LOOKUP Number.NIB0,[115,127,112,95,91,51,121,109,48,126,95,115,112,51,91,48],Dataout
' No Decode
' puts numbers equal to displayed numbers.
GOTO Dataout1
Skipit:
LOOKUP Number.NIB0,[126,95,48,112,115,121,91,48,115,127,112,95,91,121,51,109],Dataout
' No Decode
' puts numbers equal to displayed numbers.
Dataout1:
SHIFTOUT DATAIN,CLK,MSBFIRST,[Dataout\8] ' Send out
data to chip.
PULSOUT Load,1 ' Send pulse to load LED's.
RANDOM Number ' Generate random number every digit.
NEXT |