Code:
'****************************************************************
'* Name : 0832test.bas *
'* Author : aerostar *
'* Notice : Copyright (c) 2021 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 04/01/2021 *
'* Version : 1.0 *
'* Notes : *
'* : *
'****************************************************************
'****************************************************************
'****************************************************************
'Sure electronics module 0832 led matrix
'
'connect RD on module to +5v
'connect OSC on module to GND
'Sure electronics module 0832 led matrix
'
'displays XX:XX COUNTING 0 TO 9
DEFINE OSC 20
@ device PIC16F628A,HS_OSC,BOD_ON,MCLR_ON
TRISA = 0
TRISB = 0
'change your ports to suit
CS var PORTB.7 'Connect this to CS1 (set dip switchs to 1 = on 2/3/4 = off)
WR var PORTA.4 'connect this to wr ACTUALLY CLOCK BUT HOLTEK CALL IT WR
DATALINE var PORTA.1 'connect this to DATA
'connect RD on module to +5v
'connect OSC on module to GND
ALOOP VAR BYTE
COUNTER var byte
ADDRESS var byte
COMD var byte
ENDBIT var bit
CHARACTERS var byte [5]
SENDDOTS var byte
NUMBER VAR BYTE
' NUMBERS 0 TO 9 COLUMNS
data @0, %00000000,%01111100,%10001010,%10010010,%10100010,%01111100,%00000000,%00000000
data @8, %00000000,%00100010,%01000010,%11111110,%00000010,%00000010,%00000000,%00000000
DATA @16,%00000000,%01000010,%10000110,%10001010,%10010010,%01100010,%00000000,%00000000
DATA @24,%00000000,%10000100,%10000010,%10100010,%10110010,%11001100,%00000000,%00000000
DATA @32,%00000000,%00011000,%00101000,%01001000,%11111110,%00001000,%00000000,%00000000
DATA @40,%00000000,%11110100,%10100010,%10100010,%10100010,%10011100,%00000000,%00000000
DATA @48,%00000000,%01111100,%10010010,%10010010,%10010010,%01001100,%00000000,%00000000
DATA @56,%00000000,%10000110,%10001000,%10010000,%10100000,%11000000,%00000000,%00000000
DATA @64,%00000000,%01101100,%10010010,%10010010,%10010010,%01101100,%00000000,%00000000
DATA @72,%00000000,%01100100,%10010010,%10010010,%10010010,%01111100,%00000000,%00000000
CLEAR
CMCON=7
PAUSE 500
'---------------- SENDS COMMANDS-------------------------------------
COMD = %00000100 'Comand mode
ADDRESS = %00000001 'osc on
GOSUB COMANDSEND
ADDRESS = %00000011 'led on
GOSUB comandsend
ADDRESS = %10101111 'pwm 16/16
GOSUB comandsend
ADDRESS = %00011000 'RC int clk sourse on
GOSUB comandsend
'---------- SENDS IMAGE DATA TO DISPLAY-----------------------------
COMD = %00000101 'Data Mode
NUMBER=0 'SET NUMBER TO 0
SHOWNUMBERS:
ADDRESS = 0 'DIG 1 0, DIG2 16, DIG3 32, DIG4 48
FOR ALOOP =0 TO 3 ' 4 DIGITS
FOR COUNTER = 0 TO 7 ' NUMBER OF COLUMNS PER DIGIT
read (NUMBER*8)+COUNTER,SENDDOTS
IF ALOOP=1 AND COUNTER = 7 THEN
SENDDOTS=%00101000 'COLON IN COLUMN 7
ENDIF
GOSUB DATASEND
ADDRESS = ADDRESS + 2 ' ADRESS INCREMENTS BY 2 EACH COLUMN
NEXT COUNTER
NEXT
PAUSE 1000
NUMBER=NUMBER+1
IF NUMBER =10 THEN
NUMBER=0
ENDIF
GOTO SHOWNUMBERS
'----------------- sends infomation to display ----------------------
DATASEND:
LOW CS
SHIFTOUT DATALINE,wr,1,[COMD\3] 'send lower 3 bits of COMD byte
SHIFTOUT DATALINE,wr,1,[ADDRESS\7] 'send lower 7 bits of adress byte
SHIFTOUT DATALINE,wr,1,[SENDDOTS] 'send led data
HIGH CS
RETURN
COMANDSEND:
LOW CS
SHIFTOUT DATALINE,wr,1,[COMD\3] 'send lower 3 bits of COMD byte
SHIFTOUT DATALINE,wr,1,[ADDRESS] 'send command byte
SHIFTOUT DATALINE,wr,1,[ENDBIT\1] 'send 1 ENDBIT
HIGH CS
RETURN
END
Bookmarks