Hi all,
Sorry to repeat threads again, I have searched and not seen anything similar to what I'm trying to achieve.
I'm trying to make a blue and white led matrix that flashes the leds on and off to a set pattern to start with, and then maybe move on to doing it as a randomly selected leds that get turned off. But trying to start as simple as possible.
Heres a clip of something very similar https://www.youtube.com/watch?v=M_7AN8YdnLU
The code has come from a mixture of places (Westaus55 and xtech007 posts. Thanks for all your posts) as well as some of my own, as I try and learn this. What I was aiming for is col 1 gets sent first and lights the leds according to the Lookup command. It then moves onto col 2, and so on up to col 8. Once it gets to col 8 it goes back to col 1 and overwrites the leds with a different pattern. Continuously changing between the 3 patterns I have added so far.
My Code
Sorry to repeat threads again, I have searched and not seen anything similar to what I'm trying to achieve.
I'm trying to make a blue and white led matrix that flashes the leds on and off to a set pattern to start with, and then maybe move on to doing it as a randomly selected leds that get turned off. But trying to start as simple as possible.
Heres a clip of something very similar https://www.youtube.com/watch?v=M_7AN8YdnLU
The code has come from a mixture of places (Westaus55 and xtech007 posts. Thanks for all your posts) as well as some of my own, as I try and learn this. What I was aiming for is col 1 gets sent first and lights the leds according to the Lookup command. It then moves onto col 2, and so on up to col 8. Once it gets to col 8 it goes back to col 1 and overwrites the leds with a different pattern. Continuously changing between the 3 patterns I have added so far.
My Code
Code:
#Picaxe 20x2
;Setfreq M32 ; Not sure if need to set a frequency. Must check this out.
; The goal of this program is to make a 8x5 Matrix flash the leds randomly.
; There are blue and white leds in a mixed pattern in the matrix.
; Symbol Definitions
; Max7219
Symbol DIn7219 = B.0
Symbol Clk7219 = B.1
Symbol Load7219 = B.2
; MAX7219 Registers
Symbol No_Op = $00 ; No Operation
Symbol Digit0 = $01 ; Col 1
Symbol Digit1 = $02 ; Col 2
Symbol Digit2 = $03 ; Col 3
Symbol Digit3 = $04 ; Col 4
Symbol Digit4 = $05 ; Col 5
Symbol Digit5 = $06 ; Col 6
Symbol Digit6 = $07 ; Col 7
Symbol Digit7 = $08 ; Col 8
;
Symbol Decode = $09 ; Decode or No Decode
Symbol Intensity = $0A ; 10 - How bright the leds are
Symbol Scan_Limit = $0B ; 11 - How many digits to display
Symbol Shutdown = $0C ; 12 - Turn off
Symbol DigTest = $0F ; 15 - Test
;
Symbol display_on = $01 ; 1 - Display ON
Symbol display_off = $00 ; 0 - Display OFF
Symbol display_test_on = $01 ; 1 - Turns all LED's ON for test
Symbol display_test_off = $00 ; 0 - Test OFF
Symbol display_normal = $00 ; 0 - Normal Operation
Symbol blank = $0F ; 15 - Display Blanked
;
Symbol maxreg = b0 ; maxreg is the digit (column) to be displayed
Symbol maxdata = b1 ; maxdata is the LED pattern (1=on 0=off)
;
; Create random coordinates - Maybe used another day
;Symbol RandomX = w0
;Symbol RandomY = w1
;Symbol NewRandomX = w2
;Symbol NewRandomY = w3
;Symbol Repeater = w4
; Intialise ready for action
Initialise7219:
maxReg = decode
maxData = $00
gosub SendTo_Max7219
maxReg = intensity
maxData = $01
gosub SendTo_Max7219
maxReg = scan_limit
maxData = $07
gosub SendTo_Max7219
maxReg = shutdown
maxData = display_on
gosub SendTo_Max7219
pause 30
Clear_MAX7219: 'Clears the display
maxdata = $00
for maxreg = 1 to 8
gosub SendTo_Max7219
next
pause 500
Main:
;
; 1st Set of lights
;
maxReg = $01
Lookup maxData, ($00, $01, $00, $00, $01), maxData
Gosub SendTo_Max7219
maxReg = $02
Lookup maxData, ($01, $01, $00, $00, $01), maxData
Gosub SendTo_Max7219
maxReg = $03
Lookup maxData, ($00, $00, $01, $00, $00), maxData
Gosub SendTo_Max7219
maxReg = $04
Lookup maxData, ($01, $01, $00, $01, $01), maxData
Gosub SendTo_Max7219
maxReg = $05
Lookup maxData, ($00, $00, $00, $00, $00), maxData
Gosub SendTo_Max7219
maxReg = $06
Lookup maxData, ($00, $00, $01, $01, $01), maxData
Gosub SendTo_Max7219
maxReg = $07
Lookup maxData, ($01, $01, $01, $01, $00), maxData
Gosub SendTo_Max7219
maxReg = $08
Lookup maxData, ($01, $01, $00, $00, $01), maxData
Gosub SendTo_Max7219
Pause 500
;
; 2nd Set of lights
;
maxReg = $01
Lookup maxData, ($01, $00, $00, $00, $00), maxData
Gosub SendTo_Max7219
maxReg = $02
Lookup maxData, ($00, $00, $01, $01, $00), maxData
Gosub SendTo_Max7219
maxReg = $03
Lookup maxData, ($01, $00, $01, $00, $01), maxData
Gosub SendTo_Max7219
maxReg = $04
Lookup maxData, ($00, $00, $00, $00, $00), maxData
Gosub SendTo_Max7219
maxReg = $05
Lookup maxData, ($01, $00, $01, $00, $01), maxData
Gosub SendTo_Max7219
maxReg = $06
Lookup maxData, ($01, $00, $01, $01, $01), maxData
Gosub SendTo_Max7219
maxReg = $07
Lookup maxData, ($00, $00, $00, $00, $00), maxData
Gosub SendTo_Max7219
maxReg = $08
Lookup maxData, ($00, $00, $00, $00, $00), maxData
Gosub SendTo_Max7219
Pause 500
;
; 3rd Set of lights
;
maxReg = $01
Lookup maxData, ($01, $00, $01, $01, $01), maxData
Gosub SendTo_Max7219
maxReg = $02
Lookup maxData, ($00, $01, $01, $01, $00), maxData
Gosub SendTo_Max7219
maxReg = $03
Lookup maxData, ($01, $01, $01, $00, $01), maxData
Gosub SendTo_Max7219
maxReg = $04
Lookup maxData, ($00, $00, $01, $00, $01), maxData
Gosub SendTo_Max7219
maxReg = $05
Lookup maxData, ($01, $00, $01, $01, $01), maxData
Gosub SendTo_Max7219
maxReg = $06
Lookup maxData, ($01, $01, $01, $01, $01), maxData
Gosub SendTo_Max7219
maxReg = $07
Lookup maxData, ($00, $01, $00, $01, $01), maxData
Gosub SendTo_Max7219
maxReg = $08
Lookup maxData, ($01, $01, $00, $01, $01), maxData
Gosub SendTo_Max7219
Pause 500
goto main
End
;Randomise_leds:
; Random pick an X and Y location and turn that led on.
; RandomY = 5 Max. RandomX = 8 Max.
; Random RandomX
; NewRandomX = RandomX // 8 + 1
; Random RandomY
; NewRandomY = RandomY // 5 + 1
; Return
SendTo_Max7219:
LOW Load7219
SHIFTOUT Clk7219,DIn7219,1,(maxreg,maxdata)
HIGH Load7219
RETURN