prikaz displeja:
ako napisem da je Y=1 i X=%00000001 onda mi svijetli dolje desno prva dioda
87654321
00000000 ----255
00000000
00000000
00000000
00000000
00000000
00000000
00000001 -----1
----------------------------------------------------------------------------------------------------
ako napisem da je Y=1 i X=%11111111 onda mi svijetli cijeli prvi desni red
87654321
00000001 ----255
00000001
00000001
00000001
00000001
00000001
00000001
00000001 -----1
---------------------------------------------------------------------------------------------------
ako napisem da je Y=2 i X=%11111111 onda mi svijetli ova kombinacija
87654321
00000010 ----255
00000010
00000010
00000010
00000010
00000010
00000010
00000010 -----1
primjer koda s kojim to radim
Code: Select all
'****************************************************************
'* Name : UNTITLED.BAS *
'* Author : ZELJKO FERIC *
'* Notice : Copyright (c) 2014 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 13.10.2014 *
'* Version : 1.0 *
'* Notes : *
'* : *
'****************************************************************
'PIC16F877A
Define OSC 4 ' Set Xtal Frequency
TRISA = %00111111 'port a je cijeli ulazni
TRISB = %00000000
TRISC = %00000000
TRISD = %00000000
TRISE = %1111
ADCON1 = 7 ' PORTA i PORTE su digitalni ISKLJUCI KOMPARATORE I ANALOGNE ULAZE
include "modedefs.bas"
'-----VARIABLES-----
ADDRESS var word 'variable address for display
DATAREG var word 'variable data register for display
Y VAR BYTE 'okomice
X var BYTE 'sadrzaj okomice
'----- symbolos ------
SYMBOL CLK = PORTB.0
SYMBOL DAT = PORTB.1
SYMBOL LOAD = PORTB.2
'-----PIN SETUPS-----
low dat 'data pin for MAX7219 (1)
low clk 'clock pin for MAX7219 (13)
low load 'load pin for MAX7219 (12)
'-----MAX7219 SETUP-----
ADDRESS = $0C : DATAREG = $01 : gosub MaxWrite ' NO SHUT, NORMAL OPERATION
ADDRESS = $09 : DATAREG = $00 : gosub MaxWrite ' COMBINACION BINARIA, NO DECODE
ADDRESS = $0A : DATAREG = $09 : gosub MaxWrite ' INTENSIDAD DE LEDS 1(MIN) A F(MAX)
ADDRESS = $0B : DATAREG = $07 : gosub MaxWrite ' SCAN LIMIT NUMERO DE DIGITOS
ADDRESS = $0F : DATAREG = $00 : gosub MaxWrite
GOSUB brisi_display
main:
y=1
X=%11111111
ADDRESS = y
DATAREG = x
GOSUB MAXWRITE
PAUSE 2000
gosub brisi_display
pause 500
goto main
MaxWrite:
shiftout DAT,CLK,MSBFIRST,[ADDRESS,DATAREG] 'Shift out the data to the 'MAX7219 'first the address, then data.
pulsout LOAD,1 'load the data into the MAX7219
return
brisi_display:
for Y = 1 to 8 'write $0F (blank) to all digits
ADDRESS = Y : DATAREG = $00
gosub MaxWrite
next Y
return