• PicŪ Basic


  • Octobrite / TLC5947 rgb led driver example

    I have been admiring this chip TLC5947 from Texas Insturments. This awesome chip makes it super easy to drive 24 led channels of leds. For more details see the Datasheet.

    Anyways I picked up the Octobrite board from Macetech to make a quick demo of this chip easy. I plan on using this in a number of upcoming projects and thought I'd whip up some code. A quick google search didn't produce any example for picbasic so I thought I would share!




    Code:
    '****************************************************************
    '*  Name    : OCTOBRITE_A.BAS                                   *
    '*  Author  : OHARARP                                           *
    '*  Date    : 5/3/2009                                          *
    '*  Version : 1.0                                               *
    '*  Notes   : Code Designed to work with OCTOBRITE/TLC5947      *
    '****************************************************************
        Device = 18F1220
        Xtal = 10
        Declare PLL_Req = On    
        Optimiser_Level = 3
        Clear    
        All_Digital = TRUE
    '*******************************************************************************   
    'Device Fuse configuration
    Config_Start
        OSC     = HSPLL     ; Internal Oscillator with I/O on RA6 and RA7
        FSCM    = OFF        ; Failsafe Clock Monitor Disabled
        IESO    = OFF        ; Int/Ext Oscillator Switch Over Disabled
        PWRT    = OFF        ; Power Up Timer Disabled
        BOR     = OFF        ; Brownout Reset Disabled
        WDT     = OFF        ; Watchdog Timer Disabled
        MCLRE    = On        ; MCLR Disabled
        LVP     = OFF       ; Low Voltage ICSP Disabled
    Config_End  
    '*******************************************************************************   
    Dim CMD As Word
    Dim RED As Word
    Dim BLU As Word
    Dim GRN As Word
    
    Dim SO As PORTA.0 'DATA PIN
    Dim CL As PORTA.1 'CLOCK PIN
    Dim BL As PORTA.2 'BLANK PIN
    Dim XL As PORTA.3 'LATCH PIN
    
    Dim IDX_RGB As Word
    Dim IDX_SHIFT As Word
    Dim DOF As Float 'Degrees of Offset
    Dim BF  As Float         'Brightness Factor
    Dim IDX_SCAN As Float    'Scan Index
    '*******************************************************************************   
    INIT:
    GoSub OCTO_RESET
    
    MAIN:
    
    RED = 0 
    GRN = 0
    BLU = 0
    
    'CYCLE THROUGH A SET OF PATTERN - SAME FOR ALL LEDS
    For IDX_RGB = 0 To 4095 Step 500
        RED = RED + IDX_RGB
        GRN = 1024
        BLU = 4095 - IDX_RGB 
        GoSub SHIFT_OCTO
        DelayMS 250
    Next
    
    
    GoTo MAIN
    '*******************************************************************************   
    OCTO_RESET:
        High BL
        DelayMS 250
        Low BL
    Return
    '*******************************************************************************   
    SHIFT_OCTO:
        Low XL  'Low Latch
        For IDX_SHIFT = 0 To 7
            SHOut SO,CL,msbfirst,[BLU\12, GRN\12, RED\12]
        Next
        High XL 
    Return
    '*******************************************************************************
    This article was originally published in forum thread: Octobrite / TLC5947 rgb led driver example started by ohararp View original post
  • Recent Activity

    teo-16018

    Microsoft security essentials blues

    Thread Starter: shantanu@india

    Hi, A strange thing happened just now.My Windows 7 Micrsoft Sercurity Essentials suddenly gave a warning that prplus.exe(Compiler) is a potential...

    teo Today, 19:23 Go to last post
    pic-ignorant-1162

    Proton Runtime Error

    Thread Starter: Paulcc

    I have proton running well on my laptop, but after installing it on my desktop, I get the following runtime error: "Runtime Error 217 at 000709FC" I...

    pic-ignorant Yesterday, 22:11 Go to last post
    David Barker-251

    UMC bootloader 18F46K22

    Thread Starter: shunt010

    Hi all. I am trying to build a UMC bootloader file for the 18F46K22, and it doesn't appear to work. It returns (in the error log) Error ...

    David Barker Today, 11:20 Go to last post
    barak-1433

    SPI mssp

    Thread Starter: picprotonguy

    Just ordered Digital to Analog IC MCP4822 with SPI interface and immediately opened proton manual. I'm very disappointed, it looks like Proton...

    barak Today, 16:06 Go to last post