PDA

View Full Version : HT16K33 led 14 segment backpack



louislouis
- 11th April 2021, 12:10
Hi folks,

I want to ask members, someone has done working with this HT16K33 14. segment LED backpack in PBP.
https://www.adafruit.com/product/1911
I am trying to get this thing live, but no success. Any help welcome.

Thanks.

Louis

richard
- 11th April 2021, 12:59
i did post an example but its been expunged or lost when the forum crashed, all i can find on my pc is this


;7x5 led array witk ht16k33 mapped col 0-5 a0 - a6;highbyte of ROW[x] maps to a0:7 i2cread/write natively sends high byte first.
;chip actually wants data lowbyte first ~! typical
;pic12f1822
#CONFIG
__config _CONFIG1, _FOSC_INTOSC & _MCLRE_ON & _CP_OFF & _CPD_OFF
__config _CONFIG2, _PLLEN_OFF & _LVP_OFF
#ENDCONFIG


OSCCON = %01110000
DEFINE OSC 8


TRISA = %001011


ANSELA = 0 'Digital
' DEFINE DEBUG_REG PORTA
' DEFINE DEBUG_BIT 0 ; if not used for pwr
' DEFINE DEBUG_BAUD 9600
' DEFINE DEBUG_MODE 0
' pause 2000
' Debug "Start",13 ,10

' DISPLAY ON 0X21
' NO BLINK 0X81
' ROW/INT 0XA0
' BRIGHT 0XEX

scl var portA.4
sda var portA.5
Led var LATA.2

SADD VAR BYTE
ROW VAR WORD[5]
COL var byte
TMP VAR WORD
CLEAR


INIT:
i2cwrite sda,scl,$E0,[$21] 'on
i2cwrite sda,scl,$E0,[$81] 'blink off
i2cwrite sda,scl,$E0,[$E8] 'HALF BRIGHT
i2cwrite sda,scl,$E0,[$A0] 'NO INT
i2cwrite sda,scl,$E0,[SADD,ROW,ROW,ROW,ROW,ROW] ;CLEAR


Main:
COL=35
while col ;walk a led backwards through array
col=col-1
TMP=0
TMP.0[14-(COL/5)]=1
SADD = 5
WHILE SADD
SADD=SADD-1
ROW[SADD]=0
WEND
ROW[(COL//5)]=TMP
i2cwrite sda,scl,$E0,[SADD,ROW[0],ROW[1],ROW[2],ROW[3],ROW[4]]
pause 100
wend
SADD = 0
FOR ROW=0 TO 127
ROW=ROW<<8
i2cwrite sda,scl,$E0,[SADD,ROW,~ROW,ROW,~ROW,ROW]
pause 50
ROW=ROW>>8
NEXT
FOR COL=0 TO 34
TMP=0
' SADD=COL//5
TMP.0[14-(COL/5)]=1
' Debug 13,10,#COL,9,HEX TMP,9,#SADD
SADD = 5
WHILE SADD
SADD=SADD-1
ROW[SADD]=0
WEND
ROW[(COL//5)]=TMP
i2cwrite sda,scl,$E0,[SADD,ROW[0],ROW[1],ROW[2],ROW[3],ROW[4]]
pause 100
NEXT
LED=!LED
pause 500
goto main
end

louislouis
- 11th April 2021, 14:53
Thanks for reply. Not working but now more clear for me how to handle this controller. I tried init the controller with default I2c adress $70 like this:


;pic 12F1840
#CONFIG
__config _CONFIG1, _FOSC_INTOSC & _MCLRE_ON & _CP_OFF & _CPD_OFF
__config _CONFIG2, _PLLEN_OFF & _LVP_OFF
#ENDCONFIG


OSCCON = %01110000
DEFINE OSC 8


TRISA = %000000


ANSELA = 0 'Digital

scl var portA.2
sda var portA.1

SADD VAR BYTE
ROW VAR WORD[5]
COL var byte
TMP VAR WORD
CLEAR

INIT:
i2cwrite sda,scl,$70,[$21] 'on
i2cwrite sda,scl,$70,[$81] 'blink off
i2cwrite sda,scl,$70,[$E8] 'HALF BRIGHT
i2cwrite sda,scl,$70,[$A0] 'NO INT
i2cwrite sda,scl,$70,[SADD,ROW,ROW,ROW,ROW,ROW] ;CLEAR

pause 200

;send something

row=5
SADD=1

i2cwrite sda,scl,$70,[SADD,ROW[0],ROW[1],ROW[2],ROW[3],ROW[4]]


No sign of life.

richard
- 11th April 2021, 15:02
No sign of life.

would not expect any with $70 as an address , if you have a ht16k33 the address is %1110xyz0 where xyz are a2 a1 a0

if a0-a2 are set low the the address is $e0 as per my example

richard
- 11th April 2021, 15:11
not only that row[0] to [4] are set to 0 still



;pic 12F1840#CONFIG
__config _CONFIG1, _FOSC_INTOSC & _MCLRE_ON & _CP_OFF & _CPD_OFF
__config _CONFIG2, _PLLEN_OFF & _LVP_OFF
#ENDCONFIG
OSCCON = %01110000
DEFINE OSC 8 TRISA = %000000
ANSELA = 0 'Digital
scl var portA.2
sda var portA.1
SADD VAR BYTE
ROW VAR WORD[4]
COL var byte
TMP VAR WORD
CLEAR
INIT:
i2cwrite sda,scl,$e0,[$21] 'on
i2cwrite sda,scl,$e0,[$81] 'blink off
i2cwrite sda,scl,$e0,[$E8] 'HALF BRIGHT
i2cwrite sda,scl,$e0,[$A0] 'NO INT
i2cwrite sda,scl,$e0,[SADD,ROW,ROW,ROW,ROW] ;CLEAR
pause 200;send something
row[0]=5:row[1]=4:row[3]=2:row[0]=1
SADD=1 ; not sure about this might need to be 0
i2cwrite sda,scl,$70,[SADD,ROW[0],ROW[1],ROW[2],ROW[3]]

louislouis
- 11th April 2021, 15:40
That default address I got from product listing:

IIC address: default address 0X70
A0, A1, A2,: IIC data address control terminal
IIC address calculation: 0X70+A0+A1+A2 (floating is 0, shortet A0 is 1, A1 is 2, A2 is 4,
for example A0 and A2 is shorted the IIC address at this time = 0X70+1+4=0X75)

richard
- 11th April 2021, 15:55
that's for a 7 bit i2c address scheme, arla arduino. pbp uses an 8 bit address for i2c

louislouis
- 11th April 2021, 16:06
Of course, you're right. Now something happening. The display lit up and does some counting and flickering with segments.
That with your firstly posted code. Now figuring out how to display numbers and characters.

richard
- 12th April 2021, 11:15
don't lose sight of the fact that my code is for a 5 x 7 bit matrix , you have a 4 x 14 bit alpha led's