Ik heb het zo ver dat een programma alle letters van het alfabet 'scrollt'
op de Matrix LED 8*8.
Best wel grappig .
Alleen 'schokt' het nog wat, ik zou het liever wat vloeiender zien. Maar als ik de delay verlaag, gaat het te snel.
pic basic code:
Program Matrix_Kar
'Display Matrix Led 8 * 8, type 1088AS
Dim ClockPin as sbit at LATB.4 'pin 10
Latch as sbit at LATB.3 'pin 9
Datapin as sbit at LATB.2 'pin 8
Light as Byte 'Intensity
Row as Byte
i1 as word
j1 as word
const Font1 As Byte[220] = ( 'Character table
0x66, 0x66, 0x66, 0x7e, 0x66, 0x66, 0x3c, 0x00,
0x3e, 0x66, 0x66, 0x3e, 0x66, 0x66, 0x3e, 0x00,
0x3c, 0x66, 0x06, 0x06, 0x06, 0x66, 0x3c, 0x00,
0x3e, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3e, 0x00,
0x7e, 0x06, 0x06, 0x3e, 0x06, 0x06, 0x7e, 0x00,
0x06, 0x06, 0x06, 0x3e, 0x06, 0x06, 0x7e, 0x00,
0x3c, 0x66, 0x76, 0x06, 0x06, 0x66, 0x3c, 0x00,
0x66, 0x66, 0x66, 0x7e, 0x66, 0x66, 0x66, 0x00,
0x3c, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00,
0x1c, 0x36, 0x36, 0x30, 0x30, 0x30, 0x78, 0x00,
0x66, 0x36, 0x1e, 0x0e, 0x1e, 0x36, 0x66, 0x00,
0x7e, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x00,
0xc6, 0xc6, 0xc6, 0xd6, 0xfe, 0xee, 0xc6, 0x00,
0xc6, 0xc6, 0xe6, 0xf6, 0xde, 0xce, 0xc6, 0x00,
0x3c, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x00,
0x06, 0x06, 0x3e, 0x66, 0x66, 0x66, 0x3e, 0x00,
0x60, 0x3c, 0x76, 0x66, 0x66, 0x66, 0x3c, 0x00,
0x66, 0x36, 0x1e, 0x3e, 0x66, 0x66, 0x3e, 0x00,
0x3c, 0x66, 0x60, 0x3c, 0x06, 0x66, 0x3c, 0x00,
0x18, 0x18, 0x18, 0x18, 0x18, 0x5a, 0x7e, 0x00,
0x7c, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00,
0x18, 0x3c, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00,
0xc6, 0xee, 0xfe, 0xd6, 0xc6, 0xc6, 0xc6, 0x00,
0xc6, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0xc6, 0x00,
0x18, 0x18, 0x18, 0x3c, 0x66, 0x66, 0x66, 0x00,
0x7e, 0x06, 0x0c, 0x18, 0x30, 0x60, 0x7e, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
)
'===============================================================================
Sub Procedure Max_Write(Dim pRow, pDig0 as Byte)
'===============================================================================
Latch = 0
SPI1_Write(pRow)
SPI1_Write(pDig0)
Latch = 1
delay_ms(1)
End sub
'===============================================================================
Sub Procedure Max7219_Init()
'===============================================================================
Max_Write(0x09, 0x00)
Max_Write(0x0B, 0x07)
Max_Write(0x0C, 0x01)
Max_Write(0x0A, 0x00)
End sub
'===============================================================================
Sub Procedure Display_Testen() 'Testen van het display; alle LEDS aan
'===============================================================================
Max_Write(0x0F, 0x01)
DELAY_MS(50)
Max_Write(0x0F, 0x00)
DELAY_MS(50)
End sub
'===============================================================================
Sub Procedure Uitzetten_Leds() 'Leds uitzetten per Row
'===============================================================================
FOR Row = 1 to 8
Max_Write(Row, 0x00)
delay_ms(5)
NEXT Row
End sub
'===============================================================================
Sub Procedure Aanzetten_Leds() 'Leds uitzetten per Row
'===============================================================================
FOR Row = 1 TO 8
Max_Write(Row, 0xff)
delay_ms(5)
NEXT Row
End sub
'===============================================================================
Main:
'===============================================================================
OSCCON = %01110000 '8Mhz internal
ANSELA = %00000000 'Port % digital
ANSELB = %00000000 'Port % digital
TRISA = %11111111
TRISB = %00000000
PORTA = %11111111
SPI1_Init()
Max7219_Init()
Display_Testen()
delay_ms(500)
Uitzetten_Leds()
'Loop ----------------------------------------------------------------------
While True
'toon_Karakters()
For i1 = 0 to 25
for j1 = 7 to 0 step -1
For Row = 1 to 8
Max_Write(Row, Font1[(i1*8) + (Row - 1)]<< j1)
next Row
Delay_Ms(50)
next j1
for j1 = 0 to 7
For Row = 1 to 8
Max_Write(Row, Font1[(i1*8) + (Row - 1)]>>j1)
Next Row
delay_ms(50)
next j1
next i1
Wend
End.