Making a flying star effect with LEDs


Results 1 to 23 of 23

Threaded View

  1. #15
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default Matrix LED example 64 LED.

    Name:  ledmatrix.gif
Views: 1612
Size:  57.2 KB
    Try this one.
    Pot changes index value for test purposes.
    You can have 64 LEDs with this example.
    LED corresponding to Index value will turn on.
    Playing with this code, you can drive PORTB pins via MIBAM and have lots of effects.


    Code:
    @ __config _HS_OSC & _WDT_OFF & _PWRTE_OFF & _BODEN_OFF & _LVP_OFF & _CP_ALL
    
    CLEAR
    DEFINE OSC 20
    DEFINE LCD_DREG PORTD
    DEFINE LCD_DBIT 0
    DEFINE LCD_RSREG PORTD
    DEFINE LCD_RSBIT 5
    DEFINE LCD_EREG PORTD
    DEFINE LCD_EBIT 4
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2
    DEFINE LCD_COMMANDUS 2000
    DEFINE LCD_DATAUS 50
    
    DEFINE ADC_BITS 8      ' Set number of bits in result
    DEFINE ADC_CLOCK 3     ' Set clock source (rc = 3)
    DEFINE ADC_SAMPLEUS 50 ' Set sampling time in microseconds 
    CMCON = 7              ' Disable Comparator & VRef. etc.
    pauseus 10
    CVRCON = 0
    ADCON1 = 96 ' 100000    Set analog thingie.
    ADCON0 = 0              ' All analog, we just need RA0.
    TRISA = 255             ' PORTA all input. Others output.
    TRISB = 0
    TRISC = 0
    TRISD = 0
    X var PORTB
    Y var PORTC
    Index var byte
    Index2 var byte
    OldVal var byte
    Pause 10
    
    Begin:
        pause 500
        lcdout $fe,1,"Matrix Test"
        pause 1000
        
        X = 0               
        Y = 255
        
        index = 0
        oldval = 255
    
    Start:
        adcin 0, index      ' Index = max 255.
        index = index / 4   ' To get index values between 0 to 63.
        if oldval <> index then ' Act only when the number changes.
            index2 = index/8    ' X scans 8 bits.
            x = 0               ' turn it Off.
            x.0[index2] = 1     ' Set the bit in line.
            
            y = 255             ' turn all pins on (output is off).
            lookup index2,[7,15,23,31,39,47,55,63],index2   ' Get matrix line.
            y.0[index2-index] = 0                           ' Clear the bit in line (output is on)
        
        
            lcdout $fe,$c0,dec3 index , " ",dec3 index2
            pause 10   
            oldval = index
         endif    
    
        goto start
    
    end
    Last edited by sayzer; - 24th December 2011 at 17:07. Reason: percent sign does not show up in code block.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

Members who have read this thread : 0

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