HT16K33 LED Controller


+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2018
    Posts
    1

    Default HT16K33 LED Controller

    Guy next door left and gave me some LED controllers using the HT16K33 controller. Brand new in the package from Adafruit.com, Cannot even get these things to turn on. I have no use for them but now it's become man versus nature and the entire free world hangs in the balance and I refuse to give up but am using this as a learning experience and a humbling experience both. Soldered the kits together and am fairly certain the joints are good, these are pretty basic kits and not much to them. Chip is alive as I have a heartbeat that works but absolutely nothing on the lights themselves. The address is 0X70 but found a blurb about a shift left and the address should be different but I'm not certain of anything now. I cannot upload the data sheet but it is at adafruit.com LED Quad Alphanumeric Display - Blue 0.54" Digits w/ I2C Backpack
    https://www.adafruit.com/product/1912


    #IF __PROCESSOR__ = "16F887"
    #DEFINE MCU_FOUND 1
    #CONFIG
    cfg1 = _EXTRC_OSC_NOCLKOUT ; INTOSC oscillator: CLKOUT function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN
    cfg1&= _WDT_OFF ; WDT enabled
    cfg1&= _PWRTE_OFF ; PWRT disabled
    cfg1&= _MCLRE_ON ; RE3/MCLR pin function is MCLR
    cfg1&= _CP_OFF ; Program memory code protection is disabled
    cfg1&= _CPD_OFF ; Data memory code protection is disabled
    cfg1&= _BOR_OFF ; BOR enabled
    cfg1&= _IESO_OFF ; Internal/External Switchover mode is enabled
    cfg1&= _FCMEN_OFF ; Fail-Safe Clock Monitor is enabled
    cfg1&= _LVP_OFF ; RB3 pin has digital I/O, HV on MCLR must be used for programming
    cfg1&= _DEBUG_OFF ; In-Circuit Debugger disabled, RB6/ICSPCLK and RB7/ICSPDAT are general purpose I/O pins
    __CONFIG _CONFIG1, cfg1
    cfg2 = _BOR40V ; Brown-out Reset set to 4.0V
    cfg2&= _WRT_OFF ; Write protection off
    __CONFIG _CONFIG2, cfg2
    #ENDCONFIG
    #ENDIF
    INCLUDE "modedefs.bas"
    define osc 4
    TRISA = %00000000 '0 means output
    TRISB = %00000000 '1 means input
    TRISC = %00000000
    TRISD = %00000000
    TRISE = %00000000
    Ansel = %00000000
    AnselH = %00000000
    OPTION_REG = $55 ' Set TMR0 configuration and enable PORTB pullups
    'INTCON = $a0 ' Enable TMR0 interrupts
    'disable
    On Interrupt Goto tickint
    DISABLE debug
    Led var PortD.0
    Ticks var word
    A var word
    B var word
    C var word
    DataToSend var word
    pause 2000
    DataToSend = %0010000100000000
    i2cwrite PortD.2,PortD.3,$E0,$20,[%0010000100000000] 'system osc on
    pause 20
    'i2cwrite PortD.2,PortD.3,$E0,$80,[%1000000100000000] 'blinking off
    pause 20
    i2cwrite PortD.2,PortD.3,$E0,$EF,[%1110111100000000] 'dimming off
    pause 20
    i2cwrite PortD.2,PortD.3,$E0,$A0,[%1010000000000000] 'row set
    pause 20
    MainLoop:

    i2cwrite PortD.2,PortD.3,$E0,$0,[%1]
    pause 20
    i2cwrite PortD.2,PortD.3,$E0,$2,[%0000111111111111]
    pause 20
    i2cwrite PortD.2,PortD.3,$E0,$4,[%0000111111111111]
    pause 20
    i2cwrite PortD.2,PortD.3,$E0,$6,[%0000111111111111]
    pause 20


    high led
    pause 500
    low led
    pause 500
    goto mainloop
    disable
    TickInt:
    ticks = ticks + 1 ' Count pieces of seconds
    If ticks < 61 Then tiexit ' 61 ticks per second (16.384ms per tick)
    high led
    pause 2000
    low led
    ticks = 0

    TiExit:
    INTCON.2 = 0 ' Reset timer interrupt flag
    Resume
    enable

    end

  2. #2
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    303

    Default Re: HT16K33 LED Controller

    I'm not very good at this but since no one else chimed in here's my thoughts. I was looking at the data sheet and I don't see this as a settable mode. Page 61. Most people don't bother with an external oscillator.

    cfg1 = _EXTRC_OSC_NOCLKOUT ; INTOSC oscillator: CLKOUT function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN

    define osc 4 should be define OSC 4 or DEFINE OSC 4 or DeFiNE OSC 4. "Define" can be any combination but OSC needs to be capitalized.

    The oscillator setting may be incorrect but the OSC has been key to many of my designs.

    Hope it helps

  3. #3
    Join Date
    May 2013
    Location
    australia
    Posts
    1,511

    Default Re: HT16K33 LED Controller

    nice chip . very easy to use

    Code:
    ;7x5 led array with ht16k33  mapped columns  0-5  rows 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
     
    ' 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
            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
        NEXT 
        LED=!LED
        pause 500
    goto main
    end
    This is more entertaining than Free to Air TV

Similar Threads

  1. Replies: 1
    Last Post: - 13th August 2013, 14:53
  2. Replies: 2
    Last Post: - 15th December 2012, 02:19
  3. Replies: 2
    Last Post: - 14th July 2008, 22:11
  4. LED Light Controller
    By lightwaveengine in forum mel PIC BASIC
    Replies: 0
    Last Post: - 18th June 2006, 15:46

Members who have read this thread : 25

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts