Matrix de leds (author Jose Pino)

; name: jp6284

; original name: mtrx628 oct 03, 2004
; jose pino
; special chars: 01 = 4 seconds pause / pausa
; 0a = End of message
; microcontroller pic 16f628 4 mhz
Disable comparators
; improved: oct 9, 2004
; initialize display memory / inicializa la memoria del display
; there variables are the ram memory For the display
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable
variable

type
type
type
type
type
type
type
type
type
type
type
type
type
type
type
type
type
type
type
type
type
type
type
type
type
type
type
type
type
type
type

Byte
Byte
Byte
Byte
Byte
Byte
Byte
Byte
Byte
Byte
Byte
Byte
Byte
Byte
Byte
Byte
Byte
Byte
Byte
Byte
Byte
Byte
Byte
Byte
Byte
Byte
Byte
Byte
Byte
Byte
Byte

c0 at 0x40 = 1111_1110
c1 at 0x41 = 1110_1001
c2 at 0x42 = 1111_1111
c3 at 0x43 = 1111_0000
c4 at 0x44 = 1111_0000
c5 at 0x45 = 1111_1111
c6 at 0x46 = 1111_1010
c7 at 0x47 = 1111_0101
c8 at 0x48 = 1111_1111
c9 at 0x49 = 1111_0001
c10 at 0x4a = 1111_0010
c11 at 0x4b = 1111_1111
c12 at 0x4c = 1111_1111
c13 at 0x4d = 1111_0000
c14 at 0x4e = 1111_0011
c15 at 0x4f = 1111_1111
c16 at 0x50 = 1111_0100
c17 at 0x51 = 1111_1111
c18 at 0x52 = 1111_0000
c19 at 0x53 = 1111_0111
c20 at 0x54 = 1111_1000
c21 at 0x55 = 1111_1111
c22 at 0x56 = 1111_0000
c23 at 0x57 = 1111_0000
c24 at 0x58 = 1111_1111
c25 at 0x59 = 1111_1111
c26 at 0x5a = 1111_1111
c27 at 0x5b = 1111_1111
c28 at 0x5c = 1111_1111
c29 at 0x5d = 1111_1111
c30 at 0x5e = 1111_1111

variable
variable
variable
variable
variable
variable
variable
variable
variable
variable

type
type
type
type
type
type
type
type
type
type

Byte
Byte
Byte
Byte
Byte
Byte
Byte
Byte
Byte
Byte

direccion = 0 ; Pointer(index) of message On EEPROM
caracter = 0 ; character
ancho = 0 ; how many bits wide is the character
indice = 0 ; data index
t_columnas = 31 ; controls how many columns On memory display
columna = 1
columnas = 24 ; controls how many columns On display
ultima_c = 0x40 + columnas
t_display = 0 ; controls speed of display
pausa = 0 ; controls pause

variable type Bit tdisp0 at t_display: 0
variable type Bit tdisp1 at t_display: 1
variable type Bit tdisp2 at t_display: 2
variable
variable
variable
variable
variable
variable
variable
variable

type
type
type
type
type
type
type
type

Bit
Bit
Bit
Bit
Bit
Bit
Bit
Bit

car0
car1
car2
car3
car4
car5
car6
car7

at
at
at
at
at
at
at
at

caracter:
caracter:
caracter:
caracter:
caracter:
caracter:
caracter:
caracter:

0
1
2
3
4
5
6
7

port b = all Output
port a = all Output
delay 1sec
; testing display code
pin a6 = On ; Enable data signal / activa el Bit de datos
For 25 loop ; turn off all leds
pin a7 = On ; send clock signal / envia un pulso al reloj shift register
delay 10msec
pin a7 = off
delay 10msec
End loop
pin a6 = On
For 3 loop
For 255 loop ; delay del scroll, >= lento
indice = 0x40 ; direccion donde comienza memoria display
pin a6 = On ; activa la columna a desplazar
; this code controls the display(scroll, columns, character display
While indice < ultima_c loop ; hace el barrido del display(cambiar al
FSR = indice ; ancho del display)
caracter = INDF ; FSR & INDF are microcontroller registers !
port b = all Input
pin a7 = off
pin a7 = On ; scroll display / desplaza la col.
pin a6 = off
port b = caracter ; display character row / despliega valor de la columna
port b = all Output
indice = indice + 1 ; Next column / siguiente columna
delay 500usecs
End loop
End loop ; End of the scroll / termina loop del scroll
End loop
; fin de test / End of test code
indice = 0x40 ; indicates the memory display address
; direccion de la memoria del display
For 26 loop ; limpia el display
FSR = indice ; clears display
INDF = 255

indice = indice + 1
End loop
; main loop here !
; programa principal aqui !
forever loop
If direccion = 128 Then ; se acabo el mensaje? despliega espacios
direccion = 0 ; pendiente a reiniciar desde el principio
End If ; no more data On EEPROM? start over
EEPROM get character from(direccion) ; lee dato / Read the character from the ee
pom
If caracter = 10 Then ; si caracter = 10, inicia de nuevo
caracter = " " ; If character = 10, start over
direccion = 255
End If
ancho = 4 ; Define el ancho de la letra si es diferente
; startdard character is 4 bits wide
If caracter = 1 Then ; si caracter = 1, una pausa de 4 secs
pausa = 50 ; If character = 1, pause the display
; this area is defined like "ROM", defines the characteres
; esta area del programa es como la memoria rom que contiene los caracteres
Else If caracter < 33 Then ; espacio / space
ancho = 3
Else If caracter < 64 Then
If caracter = "!" Then ; decodifica el caracter.
c24 = 1000_0010 ; decode characters from EEPROM
c25 = 1111_1111
ancho = 2 ; solo Define ancho si <> a 4
Else If caracter = 34 Then ; If wide Not defined, wide = 4 bits
c24 = 0100_0111
c25 = 0001_1111
c26 = 0100_0111
c27 = 1111_1111
Else If caracter = "#" Then
c24 = 0101_0101
c25 = 0000_0000
c26 = 0101_0101
c27 = 0000_0000
c28 = 0101_0101
c29 = 1111_1111
ancho = 6
Else If caracter = "$" Then
c24 = 0101_1010
c25 = 0000_0000
c26 = 0101_0101
c27 = 1111_1111
Else If caracter = "%" Then
c24 = 0100_1101
c25 = 0011_1011
c26 = 0101_0110
c27 = 1111_1111

Else If caracter
c24 = 0101_0101
c25 = 0110_1010
c26 = 0111_0100
c27 = 1111_1111
Else If caracter
c24 = 0100_0111
c25 = 1111_1111
ancho = 2
Else If caracter
c24 = 0111_0001
c25 = 0100_1110
c26 = 1111_1111
ancho = 3
Else If caracter
c24 = 0100_1110
c25 = 0111_0001
c26 = 1111_1111
ancho = 3
Else If caracter
c24 = 0101_0101
c25 = 0110_0011
c26 = 0101_0101
c27 = 1111_1111
Else If caracter
c24 = 0001_1011
c25 = 0001_0001
c26 = 0001_1011
c27 = 1111_1111
Else If caracter
c24 = 0011_1110
c25 = 0011_1101
c26 = 1111_1111
ancho = 3
Else If caracter
c24 = 0001_1011
c25 = 0001_1011
c26 = 0001_1011
c27 = 1111_1111
Else If caracter
c24 = 0001_1100
c25 = 1111_1111
ancho = 2
Else If caracter
c24 = 0011_1101
c25 = 0011_1011
c26 = 0011_0111
c27 = 1111_1111
Else If caracter
c24 = 1111_0001
c25 = 1110_1110
c26 = 1111_0001
c27 = 1111_1111
Else If caracter
c24 = 0000_0000
c25 = 1111_1111
ancho = 2
Else If caracter
c24 = 1110_1100
c25 = 1110_1010

= "&" Then

= "'" Then

= "(" Then

= ")" Then

= "*" Then

= "+" Then

= "," Then

= "-" Then

= "." Then

= "/" Then

= "0" Then

= "1" Then

= "2" Then

c26 = 1111_0110
c27 = 1111_1111
Else If caracter
c24 = 0110_1010
c25 = 0110_1010
c26 = 1011_0101
c27 = 1111_1111
Else If caracter
c24 = 0110_0011
c25 = 0011_1011
c26 = 1011_0000
c27 = 1111_1111
Else If caracter
c24 = 1110_0010
c25 = 1110_1010
c26 = 1110_1101
c27 = 1111_1111
Else If caracter
c24 = 1111_0001
c25 = 1110_1010
c26 = 1110_1101
c27 = 1111_1111
Else If caracter
c24 = 0010_1100
c25 = 0010_1011
c26 = 1010_0111
c27 = 1111_1111
Else If caracter
c24 = 1111_0101
c25 = 1110_1010
c26 = 1111_0101
c27 = 1111_1111
Else If caracter
c24 = 1111_0110
c25 = 1110_1010
c26 = 1111_0001
c27 = 1111_1111
Else If caracter
c24 = 0101_0101
c25 = 1111_1111
ancho = 2
Else If caracter
c24 = 0011_1110
c25 = 0101_0101
c26 = 1111_1111
ancho = 3
Else If caracter
c24 = 0101_1011
c25 = 0101_0101
c26 = 0010_1110
c27 = 1111_1111
Else If caracter
c24 = 0101_0101
c25 = 0101_0101
c26 = 0101_0101
c27 = 1111_1111
Else If caracter
c24 = 0010_1110
c25 = 0101_0101
c26 = 0101_1011

= "3" Then

= "4" Then

= "5" Then

= "6" Then

= "7" Then

= "8" Then

= "9" Then

= ":" Then

= ";" Then

= "<" Then

= "=" Then

= ">" Then

c27 = 1111_1111
Else If caracter = "?" Then
c24 = 0100_1111
c25 = 0110_1010
c26 = 0010_0111
c27 = 1111_1111
End If
Else If caracter < 96 Then
If caracter = "@" Then
c24 = 0111_0001
c25 = 0100_1110
c26 = 1000_0010
c27 = 0111_0010
c28 = 1111_1111
ancho = 5
Else If caracter = "A" Then
c24 = 1111_0000
c25 = 1110_1011
c26 = 1111_0000
c27 = 1111_1111
Else If caracter = "B" Then
c24 = 0000_0000
c25 = 1110_1010
c26 = 1111_0101
c27 = 1111_1111
Else If caracter = "C" Then
c24 = 1111_0001
c25 = 1110_1110
c26 = 1110_1110
c27 = 1111_1111
Else If caracter = "D" Then
c24 = 0000_0000
c25 = 1110_1110
c26 = 1111_0001
c27 = 1111_1111
Else If caracter = "E" Then
c24 = 0000_0000
c25 = 1110_1010
c26 = 1110_1110
c27 = 1111_1111
Else If caracter = "F" Then
c24 = 0000_0000
c25 = 1110_1011
c26 = 1110_1011
c27 = 1111_1111
Else If caracter = "G" Then
c24 = 1111_0001
c25 = 1110_1110
c26 = 1110_1000
c27 = 1111_1111
Else If caracter = "H" Then
c24 = 0000_0000
c25 = 1111_1011
c26 = 0000_0000
c27 = 1111_1111
Else If caracter = "I" Then
c24 = 0000_0000
c25 = 1111_1111
ancho = 2
Else If caracter = "J" Then

c24 = 1111_1110
c25 = 1111_1110
c26 = 1110_0001
c27 = 1111_1111
Else If caracter
c24 = 0000_0000
c25 = 1111_1011
c26 = 1110_0100
c27 = 1111_1111
Else If caracter
c24 = 0000_0000
c25 = 1111_1110
c26 = 1111_1110
c27 = 1111_1111
Else If caracter
c24 = 0000_0000
c25 = 1111_0111
c26 = 1111_1011
c27 = 1111_0111
c28 = 0000_0000
c29 = 1111_1111
ancho = 6
Else If caracter
c24 = 0000_0000
c25 = 1111_0111
c26 = 1111_1011
c27 = 0000_0000
c28 = 1111_1111
ancho = 5
Else If caracter
c24 = 1111_0001
c25 = 1110_1110
c26 = 1111_0001
c27 = 1111_1111
Else If caracter
c24 = 0000_0000
c25 = 1110_1011
c26 = 1111_0111
c27 = 1111_1111
Else If caracter
c24 = 1111_0001
c25 = 1110_1100
c26 = 1111_0000
c27 = 1111_1111
Else If caracter
c24 = 0000_0000
c25 = 1110_1011
c26 = 1111_0100
c27 = 1111_1111
Else If caracter
c24 = 1111_0110
c25 = 1110_1010
c26 = 1110_1101
c27 = 1111_1111
Else If caracter
c24 = 1110_1111
c25 = 0000_0000
c26 = 1110_1111
c27 = 1111_1111
Else If caracter

= "K" Then

= "L" Then

= "M" Then

= "N" Then

= "O" Then

= "P" Then

= "Q" Then

= "R" Then

= "S" Then

= "T" Then

= "U" Then

c24 = 1110_0001
c25 = 1111_1110
c26 = 1111_1110
c27 = 1110_0001
c28 = 1111_1111
ancho = 5
Else If caracter
c24 = 1110_0011
c25 = 1111_1101
c26 = 1111_1110
c27 = 1111_1101
c28 = 1110_0011
c29 = 1111_1111
ancho = 6
Else If caracter
c24 = 1110_0001
c25 = 1111_1110
c26 = 1111_1001
c27 = 1111_1110
c28 = 1110_0001
c29 = 1111_1111
ancho = 6
Else If caracter
c24 = 1110_0100
c25 = 1111_1011
c26 = 1110_0100
c27 = 1111_1111
Else If caracter
c24 = 1110_0111
c25 = 1111_1000
c26 = 1110_0111
c27 = 1111_1111
Else If caracter
c24 = 1110_1100
c25 = 1110_1010
c26 = 1110_0110
c27 = 1111_1111
Else If caracter
c25 = 1110_1110
c24 = 0000_0000
c26 = 1111_1111
ancho = 3
Else If caracter
c25 = 0000_0000
c24 = 1110_1110
c26 = 1111_1111
ancho = 3
Else If caracter
c26 = 1111_1101
c25 = 1111_1011
c24 = 1111_0111
c27 = 1111_1111
Else If caracter
c26 = 1111_0111
c25 = 1110_1111
c24 = 1111_0111
c27 = 1111_1111
Else If caracter
c24 = 1111_1110
c25 = 1111_1110

= "V" Then

= "W" Then

= "X" Then

= "Y" Then

= "Z" Then

= "[" Then

= "]" Then

= "\" Then

= "^" Then

= "_" Then

c26 = 1111_1110
ancho = 3
End If
Else If caracter < 128
If caracter = "`" Then
c25 = 1111_0111
c24 = 1110_1111
c26 = 1111_1111
ancho = 3
Else If caracter = "a"
c26 = 1111_1000
c25 = 1111_0010
c24 = 1111_0101
c27 = 1111_1111
Else If caracter = "b"
c26 = 1111_1001
c25 = 1111_0110
c24 = 1110_0001
c27 = 1111_1111
Else If caracter = "c"
c26 = 1111_0110
c25 = 1111_0110
c24 = 1111_1001
c27 = 1111_1111
Else If caracter = "d"
c26 = 1110_0001
c25 = 1111_0110
c24 = 1111_1001
c27 = 1111_1111
Else If caracter = "e"
c26 = 1111_1010
c25 = 1111_0100
c24 = 1111_1001
c27 = 1111_1111
Else If caracter = "f"
c26 = 1110_1011
c25 = 1111_0000
c24 = 1111_1011
c27 = 1111_1111
Else If caracter = "g"
c26 = 1111_0001
c25 = 1111_0010
c24 = 1111_1010
c27 = 1111_1111
Else If caracter = "h"
c26 = 1111_1000
c25 = 1111_0111
c24 = 0000_0000
c27 = 1111_1111
Else If caracter = "i"
c24 = 1110_1000
c25 = 1111_1111
ancho = 2
Else If caracter = "j"
c26 = 1110_1001
c25 = 1111_1110
c24 = 1111_1101
c27 = 1111_1111
Else If caracter = "k"
c26 = 1111_0110

Then

Then

Then

Then

Then

Then

Then

Then

Then

Then

Then

Then

c25 = 1111_1001
c24 = 1111_0000
c27 = 1111_1111
Else If caracter
c26 = 1111_1110
c25 = 0000_0000
c24 = 1110_1110
c27 = 1111_1111
Else If caracter
c28 = 1111_1000
c25 = 1111_0111
c26 = 1111_1000
c27 = 1111_0111
c24 = 1111_1000
c29 = 1111_1111
ancho = 6
Else If caracter
c26 = 1111_1000
c25 = 1111_0111
c24 = 1111_1000
c27 = 1111_1111
Else If caracter
c24 = 1111_1001
c25 = 1111_0110
c26 = 1111_1001
c27 = 1111_1111
Else If caracter
c26 = 1111_1011
c25 = 1111_0101
c24 = 1111_1000
c27 = 1111_1111
Else If caracter
c26 = 1111_1000
c25 = 1111_0101
c24 = 1111_1011
c27 = 1111_1111
Else If caracter
c26 = 1111_0111
c25 = 1111_0111
c24 = 1111_1000
c27 = 1111_1111
Else If caracter
c26 = 1111_0101
c25 = 1111_0000
c24 = 1111_1010
c27 = 1111_1111
Else If caracter
c26 = 1111_0110
c25 = 1110_0001
c24 = 1111_0111
c27 = 1111_1111
Else If caracter
c26 = 1111_0001
c25 = 1111_1110
c24 = 1111_0001
c27 = 1111_1111
Else If caracter
c24 = 1111_0001
c25 = 1111_1100
c26 = 1111_0001

= "l" Then

= "m" Then

= "n" Then

= "o" Then

= "p" Then

= "q" Then

= "r" Then

= "s" Then

= "t" Then

= "u" Then

= "v" Then

c27 = 1111_1111
Else If caracter =
c24 = 1111_0001
c25 = 1111_1110
c26 = 1111_0001
c27 = 1111_1110
c28 = 1111_0001
c29 = 1111_1111
ancho = 6
Else If caracter =
c24 = 1111_0100
c25 = 1111_1011
c26 = 1111_0100
c27 = 1111_1111
Else If caracter =
c26 = 1111_0001
c25 = 1111_1010
c24 = 1111_0110
c27 = 1111_1111
Else If caracter =
c26 = 1111_0010
c25 = 1111_0000
c24 = 1111_0100
c27 = 1111_1111
Else If caracter =
c26 = 1110_1110
c25 = 1110_0100
c24 = 1111_1011
c27 = 1111_1111
Else If caracter =
c24 = 1110_0100
c25 = 1111_1111
ancho = 2
Else If caracter =
c26 = 1111_1011
c25 = 1110_0100
c24 = 1110_1110
c27 = 1111_1111
Else If caracter =
c26 = 1110_1111
c25 = 1110_0111
c24 = 1111_0111
c27 = 1111_1111
; Else If caracter
; c24 = 1111_1111
; c25 = 1111_1111
; c26 = 1111_1111
; c27 = 1111_1111
End If
End If

"w" Then

"x" Then

"y" Then

"z" Then

"{" Then

"|" Then

"}" Then

"~" Then

= " " Then

While ancho > 0 loop ; cuando se despliegue el char, carga otro
; character done? take other character
; re - despliega las columnas que tienen todos los leds On
; display all columns with leds On
For 3 loop
indice = 0x40 ; direccion donde comienza memoria display
; address For ram memory used For the display

pin a6 = On ; activa la columna a desplazar
; activate column(data On shift register)
assembler nop ; really little delay / pequenia pausa
While indice < ultima_c loop ; hace el barrido del display(cambiar al
FSR = indice ; ancho del display)
caracter = INDF ; scroll display / INDF is a pic register
pin a7 = off ; send a clock signal To shift register
port b = all Input ; Disable port b - no display
; apaga los leds del puerto b
pin a7 = On ; desplaza la col./ scroy column
pin a6 = off ; clock signal To shift column
; senial de clock para pasar a la sig columna
If caracter = 0 Then
port b = 0000_0000
port b = all Output
delay 200usec ; activa el puerto b / activate port b & delay
End If
indice = indice + 1 ; siguiente columna / Next column On display
End loop
End loop
; fin del re - desplegado
; End of display procedure

; scroll procedure
; procedimiento del desplegado
For 9 loop ; scroll delay / desplegado >= lento
indice = 0x40 ; direccion donde comienza memoria display
; display memory address
pin a6 = On ; activa la columna a desplazar
; activate column To display
assembler nop ; little delay
While indice < ultima_c loop ; hace el barrido del display(cambiar al ancho del
display)
; loop While EEPROM have more chars
FSR = indice ; FSR & INDF are pic registers
caracter = INDF ; frs & INDF son registros del pic
pin a7 = off
port b = all Input ; turn off port b And scroll display
pin a7 = On ; desplaza la col.
port b = caracter ; despliega valor de la columna
port b = all Output ; turn On port b
pin a6 = off ; signal To clock On shift register
indice = indice + 1 ; siguiente columna / Next column
delay 200usec
End loop
End loop ; termina loop del scroll / End of scroll
; If no pause, scroll all display
; si no hay pausa, realiza es corrimiento del display
; scrolls the display memory
If
c0
c1
c2

pausa = 0 Then
= c1
= c2
= c3

c3 = c4
c4 = c5
c5 = c6
c6 = c7
c7 = c8
c8 = c9
c9 = c10
c10 = c11
c11 = c12
c12 = c13
c13 = c14
c14 = c15
c15 = c16
c16 = c17
c17 = c18
c18 = c19
c19 = c20
c20 = c21
c21 = c22
c22 = c23
c23 = c24
c24 = c25
c25 = c26
c26 = c27
c27 = c28
c28 = c29
c29 = c30
ancho = ancho - 1 ; controla el momento de cargar otro caracter
Else ; controls when another character is needed
pausa = pausa - 1
End If
End loop ; si scroll = columnas, carga otro caracter
; If scroll = columns, load another character
direccion = direccion + 1
End loop

Sign up to vote on this title
UsefulNot useful